Ez Computerहिन्दीOpen app

Programming Fundamentals

Preview Part D: Software and Programming · Chapter 16 · 17 min read · 65 practice questions

After this chapter you will be able to

  • define an algorithm and list its properties
  • draw and read flowcharts using standard symbols
  • use the three control structures
  • explain basic data types, variables and operators
  • describe OOP concepts and common data structures
  • outline the software development life cycle and testing types
Programming Fundamentals Algorithm Finite, step-by-step Input + output Flowchart, pseudocode Flowchart Oval = start / stop Diamond = decision Parallelogram = I/O Control structures Sequence Selection: if, switch Iteration: for, while Object-oriented Class = blueprint Object = instance 4 pillars: A PIE Data structures Stack = LIFO Queue = FIFO Tree, graph, array SDLC and testing Waterfall · Agile Alpha = in-house Beta = real users
Chapter 16 at a glance Recall the flowchart symbols, control structures, stack and queue rules, and the four OOP pillars.

16.1 Algorithm

An algorithm is a finite, step-by-step procedure to solve a problem.

Properties of a good algorithm

Property Meaning
Input Zero or more inputs
Output At least one output
Definiteness Each step is clear and unambiguous
Finiteness Ends after a limited number of steps
Effectiveness Each step is simple enough to be carried out
Language independence The same algorithm can be written in any programming language

Example — find the larger of two numbers

  1. Start.
  2. Read A and B.
  3. If A > B, print A; otherwise print B.
  4. Stop.

Algorithm vs program: an algorithm is the plan for solving a problem; a program is that plan written in a programming language, so that a computer can run it. A list of coded instructions is a program.

Types of Algorithms

Type Idea
Recursive Solves a problem by calling itself with smaller inputs
Divide and conquer Splits the problem into smaller sub-problems, solves each one, then combines the answers
Greedy Always takes the best local (immediate) choice at each step
Backtracking Tries a path and goes back to try another when a path fails
Dynamic programming Solves overlapping sub-problems once and stores the results for reuse
Brute force Checks every possible option and picks the best
Randomized Uses random numbers to decide the next step
Hashing Converts data into a fixed-size value (hash) for fast lookup

16.2 Flowchart

A flowchart is a diagram of an algorithm using standard symbols.

FigureFlowchart Symbols
  1. OvalTerminal — Start / Stop
  2. ParallelogramInput / Output
  3. RectangleProcess
  4. DiamondDecision (Yes / No)
  5. ArrowFlow line
  6. Small circleOn-page connector
  7. PentagonOff-page connector
  8. Double-sided rectanglePredefined process (sub-routine)
  9. Wavy-bottom rectangleDocument

Sample: Start → Read A, B → Is A > B? → Yes: Print A / No: Print B → Stop.

Symbol Name Use
Oval (rounded) Terminal Start / Stop
Parallelogram Input / Output Read, print
Rectangle Process Calculation, assignment
Diamond Decision Yes/No or True/False question
Arrow Flow line Direction of flow
Small circle Connector Join parts on the same page
Rectangle with double sides Predefined process Call a sub-program
Bracket-shaped box joined by a dashed line Comment Explanatory note; it does not change the flow
Cylinder Database Data stored in a database or file

★ EXAM POINT — Diamond = decision; parallelogram = input/output; oval = start/stop; rectangle = processing.

Other Planning Tools

Tool Meaning
Pseudocode Algorithm written in simple English-like statements without strict syntax
Decision table Table showing conditions and the actions for each combination
Data Flow Diagram (DFD) Shows how data moves through a system
UML (Unified Modeling Language) Standard visual notation for designing software: classes, objects and their relationships

Limitation: a long or complex flowchart becomes clumsy and hard to follow. This is why pseudocode is often used for big logic.

Types of Flowcharts

What the full chapter covers

The full chapter has these sections:

  1. 16.1 Algorithm
  2. 16.2 Flowchart
  3. 16.3 Control Structures
  4. 16.4 Basic Building Blocks
  5. 16.5 Object-Oriented Programming (OOP)
  6. 16.6 Data Structures (Exam Level)
  7. 16.7 Software Development Life Cycle (SDLC)
  8. 16.8 Expression Notations
  9. Chapter Quick Revision
  10. Most Important Terms
  11. Common Confusions
  12. Rapid Recall

Sample questions from this chapter

1. Integration approach mixing top-down and bottom-up?

  1. Big-bang
  2. Top-down
  3. Sandwich
  4. Bottom-up
Show answer

Answer: C. Sandwich

Sandwich integration mixes top-down and bottom-up methods in one approach.

2. Time complexity of DFS with an adjacency list?

  1. O(log V)
  2. O(V × E)
  3. O(V)
  4. O(V + E)
Show answer

Answer: D. O(V + E)

DFS with an adjacency list takes O(V + E), since each vertex and each edge is visited once.

3. Testing done by real users before release?

  1. Beta testing
  2. Unit testing
  3. Regression testing
  4. Alpha testing
Show answer

Answer: A. Beta testing

Beta testing is done by real users before the final release, to find problems in real use.

4. Best data structure for a priority queue?

  1. Stack
  2. Heap
  3. Linked list
  4. Deque
Show answer

Answer: B. Heap

A heap is the best way to implement a priority queue, because the highest-priority item is found quickly.

5. Flowchart symbol for a database?

  1. Rectangle
  2. Diamond
  3. Parallelogram
  4. Cylinder
Show answer

Answer: D. Cylinder

The cylinder symbol stands for a database or a stored file, where data is kept.