Midterm Questions Flashcards

1
Q

Describe the binary search with proper steps?

A

Search a sorted array by repeatedly dividing the search interval in half. Begin with an interval covering the whole array. If the value of the search key is less than the item in the middle of the interval, narrow the interval to the lower half. Otherwise, narrow it to the upper half. Repeatedly check until the value is found or the interval is empty.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Describe the binary search with proper steps (Pseduo code)?

A
  1. Compare x with the middle element.
  2. If x matches with the middle element, we return the mid index.
  3. Else If x is greater than the mid element, then x can only lie in the right half subarray after the mid element. So we recur for the right half.
  4. Else (x is smaller) recur for the left half.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Define Machine Language:

A

A computer programming language consisting of binary or hexadecimal instructions which a computer can respond to directly.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Define programming language:

A

A programming language is a computer language engineered to create a standard form of commands. These commands can be interpreted into a code understood by a machine.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the difference between machine language and programming language?

A

Machine learning is the low-level programming langugage represented by 0s and 1s. It is only comprenhensible to computers and its diffcult for humans to understand.

Meanwhile, programming language allows humans to translate human intentions into executable algorithms. It is only comprehensible to humans and not to computers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Define Algorithm:

A

A set of steps that defines how a task is performed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Define Program:

A

A representation of an algorithm

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Define Programming:

A

The process of developing a program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Define Software:

A

Programs and the algorithms they represent

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Define Hardware:

A

The machinery

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How to breakdown a problem and convert them to algorithm:

A

Step 1: Obtain a description of the problem.

Step 2: Analyze the problem.

Step 3: Develop a high-level algorithm.

Step 4: Refine the algorithm by adding more detail.

Step 5: Review the algorithm.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Euclidean Algorithm

A

One of the oldest numerical algorithms still to be in common use. It solves the problem of computing the greatest common divisor (gcd) of two positive integers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Abstraction

A

The distinction between the external properties of an entity and the details of the entity’s internal composition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Data (how to store them)?

A

Numbers, text, images, sounds, and video

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Difference between algorithm and programming language

A

an algorithm is a step-by-step procedure for solving the problem while programming is a set of instructions for a computer to follow to perform a task.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Formal definition of algorithm

A

An algorithm is an ordered set of unambiguous, executable steps that defines a terminating process

17
Q

Pseudo code

A

Pseudocode is an artificial and informal language that helps programmers develop algorithms.

18
Q

Pseudo code primitives (Assignments)

A

name = expression

RemainingFunds = CheckingBalance + SavingsBalance

19
Q

Pseudo code primitives (Conditional selection)

A

if (condition):
activity

if (sales have decreased):
lower the price by 5%

20
Q

Pseudo code primitives (Repeated execution):

A

while (condition):
body

while (tickets remain to be sold):
sell a ticket

21
Q

Pseudo code primitives (Functions):

A

Def name():

example: 
def ProcessLoan():
22
Q

Outline Polya’s steps:

A

Polya created his famous four-step process for problem solving, which is used all over to aid people in problem solving:

Step 1: Understand the problem.

Step 2: Devise a plan (translate).

Step 3: Carry out the plan (solve).

Step 4: Look back (check and interpret).

23
Q

Define Iterative structures:

A

A collection of instructions repeated in a looping manner

• Examples include:
– Sequential Search Algorithm
– Insertion Sort Algorithm

24
Q

Linear search (sequential search)

A

A simple approach is to do a linear search, i.e

  1. Start from the leftmost element of arr[] and one by one compare x with each element of arr[]
  2. If x matches with an element, return the index.
  3. If x doesn’t match with any of the elements, return -1.
25
Q

Define Insertion sort

A

Insertion sort is a simple sorting algorithm that works similar to the way you sort playing cards in your hands. The array is virtually split into a sorted and an unsorted part. Values from the unsorted part are picked and placed at the correct position in the sorted part.

26
Q

How to store – text, number, image, sounds, etc.

A

Many different kinds of information can be encoded as bit patterns

• Systems for encoding information have been established for

– Text
– Numeric Data
– Images
– Sound
– Other data
27
Q

Define Error detecting code

A

Error-detecting codes are a sequence of numbers generated by specific procedures for detecting errors in data that has been transmitted over computer networks

28
Q

Error Correcting code

A

An error-correcting code is an algorithm for expressing a sequence of numbers such that any errors which are introduced can be detected and corrected (within certain limitations) based on the remaining numbers.