Program Design: Algorithms and Data Structures

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Listen to an AI-generated conversation about this lesson
Download our mobile app to listen on the go
Get App

Questions and Answers

Which of the following is the first step in designing a program?

  • Input and Output Specification (correct)
  • Program Testing and Debugging
  • Algorithm and Data Structure Design
  • Translation of Algorithm to a Programming Language

Algorithm design should occur after translation to a programming language to ensure compatibility.

False (B)

What are the specifications in program designing?

Descriptions of the desired program input and output.

An algorithm is a finite sequence of ______ that can be performed in a finite length of time to solve a problem.

<p>instructions</p>
Signup and view all the answers

Match the following terms with their descriptions:

<p>Algorithm = A finite sequence of instructions to solve a problem Data Structure = A way to organize and store data Pseudocode = Informal language to represent an algorithm</p>
Signup and view all the answers

Which is the correct definition of Algorithm?

<p>It is a finite set of instructions, which, if followed, accomplish a particular task (D)</p>
Signup and view all the answers

Data structure is the same as Data type?

<p>False (B)</p>
Signup and view all the answers

What is pseudo-language?

<p>Pseudo-Language is a combination of the informal English statements and the constructs of a programming language</p>
Signup and view all the answers

Designing Data Structure and Algorithm is expressed in ______ or pseudo language

<p>pseudocode</p>
Signup and view all the answers

Match the items of the designing program:

<p>Input and Output Specification = It involves knowing what should be the input and the output of the program. Algorithm and Data Structure Design = It involves how the algorithm will behave and what data to use. Program Testing and Debugging = It involves testing the program for errors.</p>
Signup and view all the answers

What can you say about Data structure and Algorithm?

<p>Neither is of much value woth out the other. (C)</p>
Signup and view all the answers

If you design your algorithms and data structure carefully you program needs a lot of debugging.

<p>False (B)</p>
Signup and view all the answers

Define data structure in your own words.

<p>Data structure is a way to organize data.</p>
Signup and view all the answers

Outputs are data items resulting from the ______ of an algorithm.

<p>execution</p>
Signup and view all the answers

Match the criteria of Algorithm:

<p>Input = Algorithms accepts a minimum of zero input value. Output = Output is a data items that results in execution of the algorithm. Definiteness = Every time an algorithm is presented with the same input data, the same results should be obtained.</p>
Signup and view all the answers

Which of the following is NOT necessarily a criteria of Algorithm?

<p>Subjectiveness (D)</p>
Signup and view all the answers

Finiteress is not an important criteria of an algorithm.

<p>False (B)</p>
Signup and view all the answers

What is Definiteness in Algorithms?

<p>Every time an algorithm is presented with the same input data, the same results should be obtained.</p>
Signup and view all the answers

An algorithm may have ______ or more quantities that are externally supplied.

<p>zero</p>
Signup and view all the answers

Match the step in getting the sum of positive N inputted integers:

<p>Input a positive number of integers to add. Name it N. = The program asks to input a number of integers to add. Set up a COUNTER representing the number of integers that have been read; Name it COUNT = The program should keep track of how many integers have been read. If COUNT equals N, display the value of SUM and exit. = If the counter variable EQUAL the number of inputs, it will display the variable named SUM.</p>
Signup and view all the answers

In the Algorithm on the text, about computing the sum of N inputted integers, what will happen if the Counter does not equal N?

<p>It will compute to the next number. (A)</p>
Signup and view all the answers

A computer can perform an instruction if it has insufficient information

<p>False (B)</p>
Signup and view all the answers

In an algorithm requirements what will happen if an instruction requires an division of an integer by 0?

<p>The result would be undefined.</p>
Signup and view all the answers

Outputs are ______ data items resulting from the execution of an algorithm

<p>data</p>
Signup and view all the answers

Match the phrase to its meaning in the context of algorithms:

<p>Definiteness = Consistent results for the same input Finiteness = The algorithm terminates after a finite number of steps Effectiveness = Each step is executable and produces the correct result</p>
Signup and view all the answers

Why is it important for each step in an algorithm to have a unique successor instruction?

<p>To ensure that the algorithm's execution is deterministic (A)</p>
Signup and view all the answers

An algorithm with 'definiteness' may produce differing results with the same input data.

<p>False (B)</p>
Signup and view all the answers

Provide a real-world example of an algorithm encountered daily.

<p>Following a recipe to bake a cake</p>
Signup and view all the answers

Data type refers to the kinds of ______ that a variable may hold in a given programming language

<p>data</p>
Signup and view all the answers

Match the examples to their corresponding data structures:

<p>Stack = A pile of plates where you can only take the top one Queue = A waiting line where the first person in line is served first Linked List = A chain of paperclips connected one after another</p>
Signup and view all the answers

Which scenario exemplifies effectiveness criterion of an algorithm?

<p>Providing a clear and correct output for a specific input. (A)</p>
Signup and view all the answers

In algorithm design, translating to a programming language always precedes algorithm creation.

<p>False (B)</p>
Signup and view all the answers

What is the purpose of debugging in program design?

<p>To discover and correct errors.</p>
Signup and view all the answers

The design of a _______ depends on how we want to manipulate that data.

<p>data structure</p>
Signup and view all the answers

Match the terms with their definitions:

<p>Programming Language = A formal language used to communicate instructions to a computer Input data = The data that is fed in a program. Processing = Using data to do operations in a program.</p>
Signup and view all the answers

Which are acceptable inputs to a successful algorithm?

<p>The algorithm may have zero or more quantities that are externally supplied (C)</p>
Signup and view all the answers

During coding, Debugging accounts for a large component of process regardless.

<p>False (B)</p>
Signup and view all the answers

Give at least three situations from our everyday life we often encounter algorithm through directions.

<ol> <li>Instructions on how to use a shampoo, conditioner, etc. 2. Even how to apply lotion, moisturizing cream or any beauty products. 3. Instructions on a recipe book that we must follow.</li> </ol>
Signup and view all the answers

Translating algorithm to a certain programming language refers to programming and implementation if the data _______ and _____ meet the requirement of the language

<p>structures, constructs</p>
Signup and view all the answers

Match the types of actions an algorithm does in the correct order:

<p>Input = Taking external information to be processed Process = Data getting manipulated and/or transferred Output = Data getting displayed or produced after processing</p>
Signup and view all the answers

Flashcards

Program Designing

A creative process with specific steps and techniques for creating programs.

Input and Output Specification

Knowing exactly what the program needs as input and the precise output it should produce.

Algorithm and Data Structure Design

Designing both the step-by-step process (algorithm) and how data is organized.

Translation to Programming Language

Converting the algorithm into a language the computer understands.

Signup and view all the flashcards

Program Testing and Debugging

Finding and fixing errors to ensure the program works correctly.

Signup and view all the flashcards

Algorithm

A finite sequence of instructions to solve a specific problem in a finite amount of time.

Signup and view all the flashcards

Pseudo-Language

A blend of informal English and programming constructs to represent algorithms.

Signup and view all the flashcards

Data Type

Refers to the kind of data a variable can hold in a programming language.

Signup and view all the flashcards

Data Structure

A way of organizing data; a collection of variables connected in specific ways.

Signup and view all the flashcards

Definiteness

Ensures an algorithm produces the same results with the same input every time.

Signup and view all the flashcards

Finiteness

An algorithm must complete after a limited number of steps.

Signup and view all the flashcards

Effectiveness

Each instruction must be able to be performed by a computer.

Signup and view all the flashcards

Input

Information supplied to an algorithm.

Signup and view all the flashcards

Output

Data items resulting from the execution of an algorithm.

Signup and view all the flashcards

Study Notes

How to Design/Create Programs

  • Designing a program is a creative process with specific steps and techniques.
  • The program design process involves input and output specifications.
  • It also entails algorithm and data structure design.
  • It requires translation of the algorithm into a programming language.
  • Testing and debugging the program makes up part of the design process as well.

Input and Output Specification

  • Programmers need to know precisely the required input and output for a program.
  • Specifications are accurate descriptions of the desired program input and output.

Algorithm and Data Structure Design

  • Algorithm is a finite sequence of instructions to solve a problem within a finite time.
  • Pseudo Language represents algorithms using a combination of informal English statements and programming language constructs.
  • Data type refers to the kind of data a variable can hold in a programming language.
  • A variable’s data type represents the set of values it can assume; for example, an integer variable can typically hold values from -32768 to 32767.
  • Data structure is a way to organize data, referring to a collection of variables of possibly different data types connected in various ways.
  • Data structure and algorithm are equally important and should be considered a unit.
  • Algorithm design may depend on how data are stored, and data structure design depends on how we want to manipulate the data.
  • Designing data structure and algorithm is expressed in pseudocode or pseudo-language.

Translation to Programming Language

  • A program expressed in pseudocode or pseudo-language cannot be run on a computer.
  • It must be translated into a programming language.

Program Testing and Debugging

  • Program testing and debugging should not be the most time-consuming part of programming.
  • Careful algorithm and data structure design can reduce the need for debugging.
  • Even experienced programmers use testing techniques to discover and correct errors.

Algorithms

  • Algorithm is a recipe for solving a problem.
  • An algorithm is a finite set of instructions that accomplish a particular task if followed.
  • Everyday encounters with algorithms include following directions or instructions for using products or recipes.

Criteria for Algorithms

  • Every algorithm must meet these criteria: Input, Output, Definiteness, Finiteness, and Effectiveness.

Algorithm 1-1 Example

  • The problem is to compute the sum of N inputted positive integers (N is a positive integer).
  • First a positive number representing the number of integers to add is inputted (N).
  • A COUNTER is set up to represent the number of integers read (COUNT).
  • COUNT is initialized to 0.
  • A variable named SUM is assigned and set to 0.
  • If COUNT equals N, the value of SUM is displayed, and the process exits.
  • Otherwise, COUNT is incremented by 1.
  • A number A is inputted, its value is added to SUM, and the result is stored in SUM.
  • Steps repeat from step 6.

Input

  • An algorithm may have zero or more quantities that are externally supplied.
  • Algorithm 1-1 accepts a minimum of zero input value.

Output

  • Outputs are data items resulting from the execution of an algorithm, with at least one quantity processed.
  • The output in Algorithm 1-1 is an integer representing the SUM of all numbers inputted by the user.

Definiteness

  • The same inputs should yield the same results every time the algorithm is executed.
  • There must be a unique initial instruction and successor for each instruction in an algorithm.
  • Most instructions are performed from top to bottom unless specified otherwise, and all algorithms must follow a specific sequence of instructions.
  • Algorithm 1-1 starts execution on step 1, then step 2, and so on, potentially leading to step 5 or exiting depending on the value of COUNT, with no ambiguous instruction.

Finiteness

  • An algorithm will terminate after a finite number of steps.
  • Based on Algorithm 1-1, since N is finite, the execution of the algorithm will be completed after a finite number of steps.

Effectiveness

  • Effectiveness of an algorithm is measured by whether it performs what it is supposed to do.
  • A computer cannot perform an instruction if it has insufficient information or if the result of the execution could be inherently undefined.
  • For example, division by zero would render an instruction undefined.

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

More Like This

Use Quizgecko on...
Browser
Browser