How do I store linked list datas into an array?
Answer / mahesh
If you have the predetermined length of the number of nodes
in the linked list then you could have went for arrays
initialy only .
But still if you want to store the complete linked list
into an array i think dynamic arrays are best option.
Implementation : -
Loop through the linked list till enad and copy the data
members in the linked list except the NEXT or PREV pointers
into the array.
Is This Answer Correct ? | 9 Yes | 1 No |
write a program that prompt the user to enter his height and weight,then calculate the body mass index and show the algorithm used
0 Answers Jomo Kenyatta University,
program to find the magic square using array
. Write a program using two-dimensional arrays that computes the sum of data in tows and the sum of data in columns of the 3x3 (three by three) array variable n[3][3].
U hv to enter a range from a and b and search hw many no. of times a pattern n. occurs between the range a and b. Eg :i/p:enter range :0 100 Enter pattern: 13 o/p: the no. times 13 occurred betwwn 0 to 100:1 Eg :i/p:enter range :100 1000 Enter pattern: 13 o/p: the no. times 13 occurred betwwn 100 to 1000: (in this 13,113,131,132,133…139,213,313,…913 all these will be counted)
Teta-Omeg-Big-Oh Show that f(n) = n2 + 3n3 is ;(n3).
Write a program that takes a 3 digit number n and finds out whether the number 2^n + 1 is prime, or if it is not prime find out its factors.
5 Answers ADP, Amazon, HCL, IBM, Infosys, Satyam, TCS, Vimukti Technologies,
how to take time as input in the format (12:02:13) from user so that controls remains between these columns?
What output does the following code generate? Why? What output does it generate if you make A::Foo() a pure virtual function? class A { A() { this->Foo(); } virtual void Foo() { cout << "A::Foo()" << endl; } }; class B : public A { B() { this->Foo(); } virtual void Foo() { cout << "A::Foo()" << endl; } }; int main(int, char**) { A objectA; B objectB; return 0; }
Performance Algorithm A performs 10n2 basic operations and algorithm B performs 300 lg n basic operations. For what value of n does algorithm B start to show its better performance?
0 Answers ASD Lab, Qatar University, UNV,
Deriving time complexity of Binary tree and AVL tree, step by step.
A research student is given a singly-linked list. Each node of the list has a color, which is either “Black” or “White”. He must find if there are more black nodes than white nodes, or vice versa. His advisor gives him 5,000Rs to buy a computer to do the work. He goes to the computer store and finds a slightly defective computer which costs a mere 3,000Rs. This computer has the small problem of not being able to do arithmetic. This means that he cannot use a counter to count the nodes in the list to determine the majority color. The computer is otherwise fully functional. He has the evil idea that he could buy the defective computer and somehow use it to do his work, so that he can use the rest of the money on enjoyment. Show how he can accomplish this amazing task. Write code for an algorithm called ‘findMajorityColor’ which takes a singly-linked list, L, with n nodes and returns the majority color among nodes of L. This algorithm should have the same asymptotic running time as counting the nodes (O(n)). Note: No arithmetic is allowed.
write a function that reverse the elements of an array in place.The function must accept only one pointer value and return void.