Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'m having an exam soon, this is part of the study guide and I could you some r

ID: 3702569 • Letter: I

Question

I'm having an exam soon, this is part of the study guide and I could you some really good detailed(comments) examples to study [C++]. Thanks in advance!

//------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Be prepared to implement a singly linked list or a doubly linked list from scratch.

2.Be prepared to implement a stack, queue, or priority queue using a linked list (singly or doubly linked).

3.Be prepared to implement a “weird” method that you’ve never heard of before to prove you truly understand what you are doing.  Here is an example:

a.Implement ‘void decimate()’ which deletes every 10th item from the list: https://en.wikipedia.org/wiki/Decimation_(Roman_army)

4.What is a memory leak?

//------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Also these quick function/methods, will rate! (:

4.Write a recursive function ‘int threeSum(int n)’ that returns the sum of 1+2+3+4+…+3*n.  (no loops!).  

5.Write a method that ‘int numThrees(int n)’ that returns the number of 3’s in the base 7 expansion of n.

Explanation / Answer

Solution:

For 2:

start with the data structures implementation, implement linked list first and play with it.

then learn queue and stacks and priority queues.

An example of queue implemented using singly and doubly linked list.

dequeue for singly linked list----

for doubly linked list

void dequePush(Deque d, int direction, int value)

for 3 given info is not enough to give an insight.

4)

Memory leak is when there is a buffer overflow or when there is so many recursive calls so that the stack allocated memory exceeds the limit and there is a stack overflow.

5)

int threeSum(int n)

{

int sum;

for(int i= 1; i<=3*n; i++)

{

sum+= i; //calculating the sum

}

return sum; //returning the final value after computation

}

Recursive approach:

int threeSum(int n)

{

if(n==0)

return 0;

else

return (3*n) + ((3*n )- 1) + ((3*n)-2) + threesum(n-1)

}

please respot the rest of the parts. I covered as much as I could.

I hope this helps; if you find any problem. Please comment below. Don't forget to give a thumbs up if you liked it. :)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote