← Qualcomm questions

Stack, Queue, and Function Pointers

Filed under Qualcomm

Free read 3 of 3

Define Stack as LIFO (Last In, First Out) with push/pop operations, and Queue as FIFO (First In, First Out) with enqueue/dequeue operations.

The question

Answer conceptual questions regarding Stacks and Queues, and write a code snippet demonstrating the declaration and usage of function pointers in C/C++.

Constraints

  • Must use standard C or C++ syntax for function pointers.

Approach

  1. Define Stack as LIFO (Last In, First Out) with push/pop operations, and Queue as FIFO (First In, First Out) with enqueue/dequeue operations.

Solution

O(1) time, O(1) space

Python
def add(a, b):
    return a + b

# Simulating function pointer behavior in Python
func_ptr = add
assert func_ptr(2, 3) == 5

Tips

  • What they are testing: Tests fundamental data structure knowledge (LIFO vs FIFO) and low-level language fluency with function pointers.
  • Common mistake: Incorrect syntax when declaring a function pointer, such as missing parentheses around the pointer variable name.

Follow-ups

  • Basic questions on stack and queue.
  • Write code snippet for function pointers.

Related Qualcomm questions

Collected from public candidate posts and coding forums. Updated Nov 2026.