Okay...it looks like a Binary search tree insertr. I wasn't sure if binary tree follows the same procedure. Thanks!
Type: Posts; User: lastrial
Okay...it looks like a Binary search tree insertr. I wasn't sure if binary tree follows the same procedure. Thanks!
How would you insert random int in a binary tree? eg 1,5,34,90,3,56,1. What is the logic behind inserting these nodes?
How to read data from a disk file? process end of file and process error conditions?
How do you compare bag and set? (I know set cannot have duplicates any other points?)
I am talking about pointer lists
How to remove even elements from list without using a counter?
How would I remove odd elements /even elements from a list without using a counter?
Thanks to you...I didn't realise I missed writing function name.
Awesome! very concise solution!
why doesn't this work?
int eodd(node_ptr p, int is_even)
{
if(p) return (p->next, !is_even);
Thanks verymuch guys I followed both the solutions......using mod and triggering....
Idea is to swap Binary tree's element's with it's left node. Here's the code I came up with:
TREE swap_left (TREE T){
element_type tmp;
if(T!=NULL){
if(T->left){
tmp =...
I want to remove even nodes in a singly linked list. Here's is a iterative solution I wrote, which works fine:
void remove_alternate(LIST L){
position p,tmp_cell;
int cnt;
cnt = 0;
p =...
I printed out the solution and it does look right....thanks for your answer Mac
Is this the right solution using while?
TREE swap_left (TREE T){
element_type tmp;
while ((T!=NULL) && (T->left!=NULL)){
tmp = T->element;
T->element = T->left->element;
I am really getting confused between using while and if loops
eg: Here's a solution for swapping current element with it's left node in a binary tree:
TREE swap_left (TREE T){...
Oh so...using flag++ doesn't fall under using a counter huh.....thanks for clearing that up. Thanks very much happy reaper.
I am not supposed to use a counter and code shown above uses it.
This what I have come up with.....donno where I goofed up
int counters (LIST L){
int flag = 0;
position p;
p = L->head->next;
if (p){
For the same question above, the solution given was:
int hasPathSum(struct tree_node* node, int sum) {
// return true if we run out of tree and sum==0
if (node == NULL) {
...
Here's a sample code I came up for the following question :
Given a tree and a sum, return true if there is a path from the root
down to a leaf, such that adding up all the values along the path...
Consider a singly-linked list of nodes, where each node contains an integer and a pointer.
a)Write an ITERATIVE function that returns TRUE (1) if the list has an EVEN number of nodes; otherwise...