Data Structures & AlgorithmsHardTCS NQT · Infosys
Evaluate 3 + 5 * 2 - 8 / 4 using standard precedence and integer division. What is the result?
- A. 11
- B. 12
- C. 13
- D. 15
Correct answer: A. 11
Multiplication and division come first: 5 * 2 = 10 and 8 / 4 = 2, so 3 + 10 - 2 = 11. Evaluating strictly left to right gives 2.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- The exponent operator ^ is right-associative. What is the value of 2 ^ 3 ^ 2?
- How many valid (balanced) bracket sequences of length 8 are there using one type of bracket?
- A grid has the rows ..#.., .##.., ....., #.#.# (where '.' is open and '#' is a wall; all rows have length 5). Starting from the top-left…
- A list holds 1, 1, 2, 2, 2, 3, 1, 1. Consecutive duplicates are merged into one node each. What is the sum of the values left in the list?
- How many distinct strings can be obtained from abc by swapping two adjacent characters at most once (including the original string)?
- A passenger count changes by +3, -1, +2, -2, +4, -3 at successive stops, starting from 0. What is the maximum number of passengers on…