Computing and Programming Fundamentals (C, Data Structures, Digital Logic Basics)
Computing and Programming Fundamentals tests C syntax, basic data structures, complexity, and digital logic basics. Questions are short-code and truth-table oriented.
Core rules
- C arrays are zero-indexed; an array name decays to a pointer to its first element in most expressions.
- Pointer arithmetic scales by the pointed-to type: p + 1 advances by sizeof(*p) bytes.
- malloc returns void*; check for NULL; free only heap memory. Structs copy by value unless passed by pointer.
- Stack is LIFO; queue is FIFO. Linked lists allow O(1) insertion at a known node but O(n) search.
- Binary search is O(log n) on sorted arrays; merge sort is O(n log n); bubble sort worst case is O(n^2).
- Digital logic: AND, OR, NOT, NAND, NOR; De Morgan's laws; a flip-flop stores one bit.
Worked example
int a[5] = {1,2,3,4,5}; int *p = a; printf("%d", *(p+3)); prints 4. p points to a[0]; p+3 points to a[3]; dereferencing gives the fourth element. The reasoning combines zero-based indexing with pointer scaling.
Traps
Using index 5 on a 5-element array; confusing p++ with (*p)++; assuming sizeof(array) inside a function gives the array size; and mixing up NAND with NOR truth tables.