Data Structures and Algorithms Flashcards

1
Q

What is an algorithm?

A

An algorithm is a set of finite steps, aimed at providing a solution to a problem

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

What are the charateristics/properties of an algorithm?

A
  1. Input/Output: Algorithms can take in 0 or more inputs, but must always produce some sort of output
  2. Finiteness: Algorithms must have a finite number of steps
  3. Definiteness: Every step of an algorithm must be clearly stated and unambigous
  4. Effectiveness: Every step of an algorithm must be able to be converted into a programming language
  5. Generality: An algorithm must be able to accept all inputs in it’s valid set of inputs, to produce the desired output
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the categories of algorithms?

A

Algorithms are categorised based on how their instructions are executed.
1. Sequencial algorithms: Here every instruction is executed, and they are executed in a succesive manner
2. Selective algorithms: Here every the execution or omision of certian instructions depends on if a certain condition is fuffilled or not
3. Iterative algorithms: These are algorithms where intructions or sets of instructions are repeated a number of times

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

How is the performance analysis of an algorithm done?

A

The efficeincy of algorithms is determined by how much time or space(memory) they require to complete execution, algorithms are said to be efficent if they
require the least amount of space(memory) or time to complete execution. The two ways of determining an algorithm’s efficiency are:

  1. Space complexity: This is the amount of space(memory) required by an algorithm to complete execution
  2. Time complexity: This is the amout of time required by an algorithm to complete execution
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is asymtotic analysis and what are asymtotic notations?

A

Asymtotic analysis is a mathematical way of figuring out the effiency of algorithm, it is solely dependent on the input of the algorithm and it is done with the help
of asymtotic notations, whtich are mathematical notations used to reppresent the effiency of algorithms

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

What are the types of efficiency/scenariors of algorithms?

A
  1. Worst case: The maximum time or memory(space) required by an algorithm to complete execution
  2. Average case: The typical or average time or space required by an algorithm to complete execution
  3. Best case: The minimum time or memery(space) required by an algorithm to complete execution
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are some asymtotic noations used?

A

Asymtotic notations are used to represent the different scenerios of algorithms, big Oh (O) for worst case, Omega() for best case, and Teta() for best and worst case

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

What are the Issues that come about when designing an algorithm?

A

How to design and how to analyze the algorithm

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

what are the types of brute force algorithms?

A

Sacrificing and Optimizing Algorithms

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

What are the different design approaches to algorithms?

A

Design an algorithm can be approached in 1 of 5 ways that include:
1. Brute force algorithms: These are algorithms where every potential solution to a problem is tried until the solution is found

  1. Divide and Conquer: These are algorithms where a problem is divided into smaller problems, each is solved and their solutions are combined to solve the initial problem
  2. Greedy Algorithms: These are algorithms where the optimal decision is made at every step of the algorithm with the aim of producing the optimal solution
  3. Branch and bound algorithms: These are algorithms where every possible solution to a problem is analyzed to find the most efficient solution
  4. Randomized algorithms: These are algorithms where random bits are added to the input to produce randomized outputs
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Which algorithm is used only in integer programming?

A

Branch and Bound algorithms

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

Differentiate between Priori and Posterior Analysis.

A

Priori Analysis is the analysis of an algorithm before it is implemented. Posterior analysis is the analysis of an algorithm after its implementation

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

What is the performance analysis of an algorithm?

A

It is analyzing an algorithm and predicting how much space(memory) or time it will require to complete execution based on its input

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

What are the types of algorithms that exist?

A

insertion, deletion, updation, search and sorting algorithms

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

What is a data structure?

A

A data structure is a set of data elements that provide an efficient way to store, organize, and use data in the computer.

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

Why do we need data structures?

A

When data is stored in increasingly large amounts, and the data is not stored and organized efficiently through the use of data structures, 3 problems arise:

  1. Processing: Large amounts of processing speeds are required to handle the data, and the processor is likely to fail
  2. Searching: Searching through the data becomes slow and inefficient
  3. Multiple requests: If the data is stored on a server, the more the request for the data from that server the more likely it is to fail
17
Q

What are the advantages of data structures?

A
  1. Efficiency: The efficiency of a program depends on the data structure used e.g In a searching algorithm it is better to use a binary search tree or sorted array, to
    reduce the number of traversals needed for searching, and increase efficiency.
  2. Re-usability: Data structures only need to be implemented once and can be used multiple times throughout the program.
  3. Abstraction: Data structures provide abstraction as they can be used by client programs that do not know about the details of their implementation
18
Q

How are data structures classified?

A

Data structures are of two types: primitive and nonprimitive
primitive data structures include: int, float, char, e.t.c
nonprimitive data structures include: Linear and Nonlinear data structures
nonlinear data structures include: trees and graphs
linear data structures include: static and dynamic data structures
static data structures include: arrays
dynamic data structures include: stacks, queues, linked list

19
Q

What is a linear data structure and what are the types of linear data structures?

A

Linear data structures are data structures whose data elements are organized in a linear and non-hierarchical manner they include:
1. Arrays: A collection of data elements of the same data type, that share the same name but different positions/indexes within the collection
2. Linked List: A collection of elements called nodes, each node containing data and a pointer pointing to the next node in the collection
3. Stacks: Linear data structures where insertion and deletion are done at one end called the top
4. Queues: Linear data structures where insertion is done at one end called the rear and deletion is done at the other end called the front

20
Q

What is a non-linear data structure and what are the types of non-linear data structures?

A

A nonlinear data structure is a data structure whose elements are organized in a nonsequential manner and elements can be connected to multiple other elements. They
include:
1. Trees: A multilevel data structure where data elements are called nodes, nodes up a level are called parents, and the nodes connected to them on a level below are called
children, the topmost node is called the root node, and the bottom-most nodes are called the leave node, each node can have multiple children and a parent except the leave nodes
and the root node respectively

  1. Graphs: A data structure, with data elements called nodes each node can be connected to multiple other nodes through a link called an edge
21
Q

What is the difference between a graph and a tree?

A

Graphs can form a cycle while tress cannot

22
Q

What are the types of operations that can be performed on a data structure?

A

There are 6 operations that can be performed on data structures which include:
1. Traversal: When every element in the data structure is visited
2. Inserting: When an element is added to the data structure
3. Deleting: When an element is removed from the data structure
4. Searching: When the position of an element in the data structure is located
5. Sorting: When elements are arranged in a specific order
6. Merged: When multiple data structures are fused together to form a single data structure

23
Q

What is a function and what are its characteristics?

A

A function is a self-contained block of code, that can be invoked multiple times throughout a program, its characteristics include the following:
1. Modularity: Fuctions allow code to be broken down into smaller parts that perform specific tasks
2. Reusability: Once a function is defined it can be used multiple times throughout a program
3. Input/Output: Functions take in inputs as parameters and can return output
4. Scope: Variables created within a function, can only be accessed from within that function
5. Signature: Functions have a signature that includes their: Name, Input Parameters, and the data type of the value they return

24
Q

What are some advantages of functions?

A
  1. They make modularity possible making code more readable, maintainable and manageable
  2. They are reusable, which reduces code duplication
25
Q

What are the types of functions that exist?

A

There is 3 main types of functions and many others, the main three are:
1. Built-in functions: These are functions provided by a programming language or its standard libraries
2. User-defined functions: These are functions created by the programmer
3. Library functions: These are functions provided by a library that is not part of the standard libraries of the programming language
4. Other types of functions include: Recursive functions, Lambda functions, Higher-order functions, e.t.c

26
Q

What are the tools used by programmers to plan the logic of their programs/solutions?

A

Pseudo-code and Flow charts

27
Q

What is a flow chart?

A

A flow chart is a pictorial representation of the logical steps required to solve a problem

28
Q

What is pseudo-code?

A

Pseudo-code is a set of logical steps required to solve a problem, that looks like they have been written in a programming language but does not use the syntax of any programming language

29
Q

What are the symbols used in a flow chart and what are their roles?

A
  1. Ovals: to start or stop the program
  2. arrows: to show the flow of the program
  3. rectangles: to indicate a process
  4. Diamonds: to make decisions(if statements)
  5. Pallalelograms: to collect input or display output
30
Q

What is a program?

A

A program is a set of executable steps, written in a programming language

31
Q

What are the characteristics of programs?

A
  1. They are written and implemented in specific programming languages
  2. They are executable by computers
  3. They can be edited or updated during execution
32
Q

What are the differences between algorithms and programs?

A
  1. Algorithms are Abstract and are sets of steps required for solving a problem, programs are concrete implementations of algorithms
  2. Algorithms are not bound to any programming language, while programs are written in a specific programming language
  3. Algorithms are not directly executed by computers but programs are directly executed by computers
33
Q

How do you create variables in VB.net

A

Dim varname As Datatype

34
Q

How do you print and input data in VB.net

A

Console.WriteLine(“text”)
Console.ReadLine()

35
Q

How do you join strings when printing?

A

Using &