pseudocode

Pseudocode in java? [closed]

此生再无相见时 提交于 2021-02-08 11:47:20
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 8 years ago . String s = ""; myf = new Finch(); do { //Run the menu until quit or cancel is selected s = FinchMenu(); //menu 1 if (s.equals("Back and forward")) RunAccelerationTest(s); } How would you convert something like

Calculate absolute difference |A-B| in assembly using only INC, DEC, JNZ, HALT - interview question

泄露秘密 提交于 2021-02-08 03:31:55
问题 This is a question I encountered in an interview and for which I didn't find a solution - so I tried to solve it myself. We can use pseudocode here - it doesn't need to be a formal code. The question is to get the absolute difference of unsigned inputs: Assume your assembly language includes ONLY the following instructions: inc , dec , jnz and halt ( halt = stop running). Task: A and B are registers that hold non-negative values. The program should calculate the value of |A-B| and locate the

Algorithms in O(n^2) vs O(n) [duplicate]

╄→尐↘猪︶ㄣ 提交于 2021-02-07 09:22:40
问题 This question already has answers here : What is the difference between O, Ω, and Θ? (6 answers) Closed 6 years ago . I'm new to computer science and just started with pseudocodes and I have some questions. It's my third week in the semester and majority is self-studying. I have some questions: What is the difference of an O(n^2) with an O(n) algorithm? - Similarly, what is O(n log n)? - and Ω(n^2)? So far, I have written: horner = 0; for( i = n; i >= 0; i −− ) horner = x * horner + a[i]; But

I know how Merge Sort works, but How Merge Sort Code Works?

旧巷老猫 提交于 2021-01-29 02:30:31
问题 You can read this on Wikipedia: function merge_sort(list m) // Base case. A list of zero or one elements is sorted, by definition. if length(m) <= 1 return m // Recursive case. First, *divide* the list into equal-sized sublists. var list left, right var integer middle = length(m) / 2 for each x in m before middle add x to left for each x in m after or equal middle add x to right // Recursively sort both sublists left = merge_sort(left) right = merge_sort(right) // Then merge the now-sorted

I know how Merge Sort works, but How Merge Sort Code Works?

旧巷老猫 提交于 2021-01-29 02:23:54
问题 You can read this on Wikipedia: function merge_sort(list m) // Base case. A list of zero or one elements is sorted, by definition. if length(m) <= 1 return m // Recursive case. First, *divide* the list into equal-sized sublists. var list left, right var integer middle = length(m) / 2 for each x in m before middle add x to left for each x in m after or equal middle add x to right // Recursively sort both sublists left = merge_sort(left) right = merge_sort(right) // Then merge the now-sorted

Do I have to make a new pipe for every pair of processes in C?

怎甘沉沦 提交于 2021-01-29 01:51:29
问题 If I have 4 processes that I want to pipe: process1 | process2 | process3 | process4 do I have to make 3 individual pipes likes this int pipe1[2]; int pipe2[2]; int pipe3[2]; or can I somehow recycle pipe names like in this pseudocode: int pipe1[2]; // we use ONLY two pipe names: pipe1 int pipe2[2]; // and pipe2 pipe(pipe1); // getting 2 file descriptors here pipe(pipe2); // and 2 here for process=1 to 4 if (process==3) // getting 2 new file descriptors for pipe(pipe1); // process3|process4

Do I have to make a new pipe for every pair of processes in C?

泪湿孤枕 提交于 2021-01-29 01:40:12
问题 If I have 4 processes that I want to pipe: process1 | process2 | process3 | process4 do I have to make 3 individual pipes likes this int pipe1[2]; int pipe2[2]; int pipe3[2]; or can I somehow recycle pipe names like in this pseudocode: int pipe1[2]; // we use ONLY two pipe names: pipe1 int pipe2[2]; // and pipe2 pipe(pipe1); // getting 2 file descriptors here pipe(pipe2); // and 2 here for process=1 to 4 if (process==3) // getting 2 new file descriptors for pipe(pipe1); // process3|process4

Do I have to make a new pipe for every pair of processes in C?

狂风中的少年 提交于 2021-01-29 01:39:55
问题 If I have 4 processes that I want to pipe: process1 | process2 | process3 | process4 do I have to make 3 individual pipes likes this int pipe1[2]; int pipe2[2]; int pipe3[2]; or can I somehow recycle pipe names like in this pseudocode: int pipe1[2]; // we use ONLY two pipe names: pipe1 int pipe2[2]; // and pipe2 pipe(pipe1); // getting 2 file descriptors here pipe(pipe2); // and 2 here for process=1 to 4 if (process==3) // getting 2 new file descriptors for pipe(pipe1); // process3|process4

Do I have to make a new pipe for every pair of processes in C?

久未见 提交于 2021-01-29 01:37:34
问题 If I have 4 processes that I want to pipe: process1 | process2 | process3 | process4 do I have to make 3 individual pipes likes this int pipe1[2]; int pipe2[2]; int pipe3[2]; or can I somehow recycle pipe names like in this pseudocode: int pipe1[2]; // we use ONLY two pipe names: pipe1 int pipe2[2]; // and pipe2 pipe(pipe1); // getting 2 file descriptors here pipe(pipe2); // and 2 here for process=1 to 4 if (process==3) // getting 2 new file descriptors for pipe(pipe1); // process3|process4

What does overflowing mean in this case?

随声附和 提交于 2021-01-27 19:40:26
问题 I have found an algorithm to multiply in modoulus. The next pseudocode is taken from wikipedia, page Modular exponention, section Right-to-left binary method. The full pseudocode is function modular_pow(base, exponent, modulus) Assert :: (modulus - 1) * (modulus - 1) does not overflow base result := 1 base := base mod modulus while exponent > 0 if (exponent mod 2 == 1): result := (result * base) mod modulus exponent := exponent >> 1 base := (base * base) mod modulus return result I don't