GATE Computer ScienceEasyGATE CS (PYQ pattern)
Non-negative numbers are stored as singly linked lists of digits with the least significant digit first. A = 9 -> 9 -> 8 -> 5 (the number 5899) and B = 7 -> 2 -> 9 (the number 927) are added digit by digit with a carry. What is the resulting list?
- A. 6 -> 2 -> 8 -> 6
- B. 6 -> 8 -> 2 -> 6
- C. 4 -> 1 -> 7 -> 0 -> 1
- D. 6 -> 1 -> 7 -> 6
Correct answer: A. 6 -> 2 -> 8 -> 6
5899 + 927 = 6826, stored least significant digit first: 6 -> 2 -> 8 -> 6.
Practise more Programming and Data Structures (GATE) questionsProgramming and Data Structures (GATE): notes and key points
More Programming and Data Structures (GATE) questions
- A priority queue is a sorted singly linked list (ascending). Insert scans from the head, comparing the new key with each node, and stops…
- Keys 1..7 form a max-heap stored in a 0-indexed array (children of i are 2i+1, 2i+2). The key 5 is the third largest. In how many…
- A hash table starts with 7 slots, uses linear probing with h(k) = k mod size, and after each insertion, if the load factor exceeds 0.7, it…
- A grid (S start, T target, # blocked, . free) is searched by BFS with 4-directional moves: S.#..... .##.###. ....#... .##.#.#. ...#..#T…
- How many 10-bit unsigned values x (0 to 1023) have no two adjacent 1 bits, where bit 9 and bit 0 also count as adjacent (the bits are…
- unsigned g(unsigned n) { return n ^ (n >> 1); } For which 8-bit n is g(n) == 0xB5? Give n in decimal.