pseudocode

Pseudocode to compare two trees

感情迁移 提交于 2019-12-03 06:57:02
问题 This is a problem I've encountered a few times, and haven't been convinced that I've used the most efficient logic. As an example, presume I have two trees: one is a folder structure, the other is an in-memory 'model' of that folder structure. I wish to compare the two trees, and produce a list of nodes that are present in one tree and not the other - and vice versa. Is there an accepted algorithm to handle this? 回答1: Seems like you just want to do a pre-order traversal, essentially. Where

Standards for pseudo code? [closed]

北慕城南 提交于 2019-12-03 04:14:23
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 11 months ago . I need to translate some python and java routines into pseudo code for my master thesis but have trouble coming up with a syntax/style that is: consistent easy to understand not too verbose not too close to natural language not too close to some concrete programming

Optimizing queries for the next and previous element

半腔热情 提交于 2019-12-03 03:06:49
问题 I am looking for the best way to retrieve the next and previous records of a record without running a full query. I have a fully implemented solution in place, and would like to know whether there are any better approaches to do this out there. Let's say we are building a web site for a fictitious greengrocer. In addition to his HTML pages, every week, he wants to publish a list of special offers on his site. He wants those offers to reside in an actual database table, and users have to be

Looking for Pseudo-code for Fortune's algorithm

别等时光非礼了梦想. 提交于 2019-12-02 22:03:21
I'd really appreciate if someone who ever dealt with Fortune's algorithm for generating Delaunay-triangulations presented me a rather low-level pseudo-code of the algorithm! I read the one on wikipedia but it's a bit confusing and looks high-level, and any piece of code I could find had the original C implementation's inconveniences. I'd like to implement it in C++, but in a way that the output generated is in the form of (my own) classes I'm going to use (vertices, edges and triangles as objects). So I need to understand everything and implement it from scratch. I also read the description of

Pseudocode to compare two trees

北城余情 提交于 2019-12-02 20:33:17
This is a problem I've encountered a few times, and haven't been convinced that I've used the most efficient logic. As an example, presume I have two trees: one is a folder structure, the other is an in-memory 'model' of that folder structure. I wish to compare the two trees, and produce a list of nodes that are present in one tree and not the other - and vice versa. Is there an accepted algorithm to handle this? Seems like you just want to do a pre-order traversal, essentially. Where "visiting" a node means checking for children that are in one version but not the other. More precisely: start

Standards for pseudo code? [closed]

本小妞迷上赌 提交于 2019-12-02 17:32:16
I need to translate some python and java routines into pseudo code for my master thesis but have trouble coming up with a syntax/style that is: consistent easy to understand not too verbose not too close to natural language not too close to some concrete programming language. How do you write pseudo code? Are there any standard recommendations? I recommend looking at the "Introduction to Algorithms" book (by Cormen, Leiserson and Rivest). I've always found its pseudo-code description of algorithms very clear and consistent. An example: DIJKSTRA(G, w, s) 1 INITIALIZE-SINGLE-SOURCE(G, s) 2 S ← Ø

MapReduce sort by value in descending order

时间秒杀一切 提交于 2019-12-02 15:55:58
问题 I'm trying to write in pseudo code a MapReduce task that returns the items sorted in descending order. For example: for the wordcount task, instead of getting: apple 1 banana 3 mango 2 I want the output to be: banana 3 mango 2 apple 1 Any ideas of how to do it? I know how to do it in ascending order (replace the keys and value in the mapper job) but not in descending order. 回答1: Here you can take help of below reducer code to achieve sorting in descending order . Assuming you have written

Optimizing queries for the next and previous element

此生再无相见时 提交于 2019-12-02 15:12:40
I am looking for the best way to retrieve the next and previous records of a record without running a full query. I have a fully implemented solution in place, and would like to know whether there are any better approaches to do this out there. Let's say we are building a web site for a fictitious greengrocer. In addition to his HTML pages, every week, he wants to publish a list of special offers on his site. He wants those offers to reside in an actual database table, and users have to be able to sort the offers in three ways. Every item also has to have a detail page with more, textual

Make math operations on a grouped table

一笑奈何 提交于 2019-12-02 15:08:50
问题 My problem is not in a real programming Language. I have an exercise in ABAP Language but is not very important the language. Anyway, I have a table: I need to make the total cost of the position(after the select obviously). Then, the table will be grouped by two fields (MATNR and BUKRS), so I need to know for each Group the total cost MAX, the total cost MIN and the total cost AVERAGE of the positions. However I need a simple algorithm to solve this problem (pseudo-code). I hope I was clear.

Can you quickly tell me if this pseudocode makes sense or not?

怎甘沉沦 提交于 2019-12-02 14:33:40
I believe my code is now foolproof. I will write up the pseudocode now. But I do have one question. Why does DRJava ask that I return something outside of my if statements? As you can see I wrote for ex: "return 1;" just because it asked. It will never return that value however. Can someone explain this to me? public class assignment1question2test { public static void main(String[] args) { int[] a = new int[50]; int l = 0; int r = a.length; for(int i=0; i<r; i++) { a[i] = 1; } a[0] = 10; for (int i=0; i<r; i++) { System.out.println(a[i]); } System.out.print(recursiveSearch(a,l,r)); } public