An algorithm is a precise plan (in the format of a sequence of steps) on how to solve a particular problem.
1
vote
0answers
7 views
Print all path from root to leaves - code review request
Ok, code reviewers, I want you to pick my code apart and give me some feedback on how I could make it better or more simple.
public class PrintAllPath {
private TreeNode root;
private class ...
1
vote
3answers
27 views
A character array of arbitary length with 'R', 'B', 'W' is needed to be sorted in that order
There is a char array of n length. The array can have elements only from
any order of R, B, W. You need to sort the array so that order should R,B,W
(i.e. all R will come first followed by B ...
3
votes
0answers
18 views
non-recursive tree traversal, code review request
Ok, code reviewers, I want you to pick my code apart and give me some feedback on how I could make it better or more simple.
public class NonRecursiveTraversal {
private TreeNode root;
...
1
vote
1answer
26 views
Print path(leaf to root) with max sum in a binary tree - code review request
Ok, code reviewers, I want you to pick my code apart and give me some feedback on how I could make it better or more simple.
public class MaxSumPath {
private TreeNode root;
private static ...
1
vote
0answers
10 views
Find inorder successor - critique request
Ok, code reviewers, I want you to pick my code apart and give me some feedback on how I could make it better or more simple. This code would find inorder successor in a binary tree.
public class ...
0
votes
0answers
29 views
Why sum is not 6 with this parallel algorithm [on hold]
Why sum is not 6 with this parallel algorithm
/*
integer B[1..n]
forall i in 1 : n do
B[i] := ai
enddo
for h = 1 to k do
...
0
votes
0answers
11 views
What are the code pattern for the parallel algorithm [on hold]
There four class of PRAM model, any examples to show them?
EREW (Exclusive Read Exclusive Write)
CREW (Concurrent Read Exclusive Write)
ERCW (Exclusive Read Concurrent Write)
CRCW (Concurrent Read ...
4
votes
1answer
63 views
The longest alternating sequence in C++
The first line of the input stream contains integer n. The second line contains n (1 <= n <= 1000) integers { a[1], a[2], a[3], ... , a[n] }, abs(a[i]) < 10^9.
Find the longest alternating ...
2
votes
1answer
38 views
Convert tree to circular doubly Linkedlist - critique request
Ok, code reviewers, I want you to pick my code apart and give me some feedback on how I could make it better or more simple.This code converts a binary tree to a doubly linkedlist (indorder).
public ...
1
vote
2answers
21 views
Print periphery of a binary tree, critique request
Ok, code reviewers, I want you to pick my code apart and give me some feedback on how I could make it better or more simple. This code will traverse peripheri ( clock and anticlockwise ) in O(n) just ...
1
vote
0answers
29 views
Construct a tree given pre and inorder Or post and inorder - critique request
Ok, code reviewers, I want you to pick my code apart and give me some feedback on how I could make it better or more simple. For a Full-Tree (all nodes with 0 or 2 children) it works ...
2
votes
1answer
96 views
How to write better an sqrt (square root) function in Scala
As an exercise in learning Scala, I implemented a square root function like this:
def sqrt(x: Double): Double = {
if (x < 0) throw new IllegalArgumentException("negative numbers not ...
0
votes
0answers
16 views
Displaying overlapping blocks using d3js
The code takes in nodes with different start time as input and assigns the position such that they will not overlap. As I have coded with too many loops and conditions. Can anyone review the code and ...
1
vote
2answers
93 views
how to reduce execution time and complile time of this program?
I have one programming question
and what did i try:
public class Trigonometric_Ratios
{
int factorial(int number)
{ int result = 1;
for (int i = 1; i <= number; i++)
{
result ...
0
votes
0answers
22 views
Recursive JSON walk in Python
I wrote this JSON walker to help with moving objects around while updating Legacy JSONs to match a new schema. Please let me know how I could further optimize it, or more importantly, make it easier ...