CodingReported in a candidate post, Aug 2020
Linked List, Stack, and Queue Implementation
Filed under Deutsche Bank
Free read 2 of 3Create a struct or class 'Node' containing an integer data field and a pointer to the next node.
The question
Implement a Singly Linked List, a Stack using a Linked List, and a Queue using a Linked List in C++.
Constraints
- Must support basic operations: push/pop for stack, enqueue/dequeue for queue, and insert/delete for list.
- Memory management must be handled (delete nodes).
- Time complexity for push/pop/enqueue/dequeue should be O(1).
Examples
- Input
- Stack.push(10), Stack.pop()
- Output
- 10
- Why
- Stack follows LIFO; last element pushed is first popped.
Approach
Create a struct or class 'Node' containing an integer data field and a pointer to the next node.
Maintain a head pointer. Implement insertion at the beginning or end and traversal.
Stack uses LIFO (push/pop at head). Queue uses FIFO (enqueue at tail, dequeue at head).
Tips
- What they are testing: Focus on edge cases like popping from an empty stack or deleting from an empty list.
- Common mistake: Failing to update the 'head' or 'tail' pointers correctly, leading to memory leaks or segmentation faults.
Related Deutsche Bank questions
Collected from public candidate posts and coding forums. Updated Nov 2026.