Full paper 1 flashcards

studied byStudied by 0 people
0.0(0)
get a hint
hint

What is a stack

1 / 64

65 Terms

1

What is a stack

Stack uses a last in first out system

  • must declare a size for it

  • push - adding a value - stack can’t be full

  • pop -

New cards
2

what does push do in stack

  • push - adding a value - stack can’t be full

<ul><li><p>push - adding a value - stack can’t be full </p></li></ul>
New cards
3

what does pop do in stack

  • pop removes item from stack make sure stack isn’t empty

New cards
4

what does peek do in a stack

allows you to look at the item at the top of the stack - stack can’t be empty

New cards
5

What are the steps for pop

  1. make sure stack isn’t empty

  2. If stack is empty display an error message

  3. if not empty increment stack pointer by 1 and add data item to stack

New cards
6

what is stack used for

  1. used in memory to store data temporarily

  2. undo button

New cards
7

What are the steps for push

  1. check is stack is empty

  2. if yes display a appropriate error message

  3. if not copy the data item location and decrement it by SP by 1

    Note that this doesn’t delete the item in the stack it will just overwrite it in the next stack

New cards
8

What are ques

they use first in first out

  • they have 2 pointer 1 back pointer and 1 front pointer

  • you can only add/ remove items in a que

New cards
9

What is linera que

  • there are linear ques: Adding item from the back removing items from the front

  • if you add an item increment rear pointer

  • if you remove an item increment front pointer

New cards
10

What is circular que

  • Also has 2 pointers

  • when item is added rear pointer is incremented, also increment number of items

  • when items are removed front pointer is incremented, decrement number of item

  • keeps track of number of items in que

  • if que is rear front pointer will be one behind the front pointer

  • if que is empty fp =rp

New cards
11

What are the cons of Linear ques

  • it is extremely space inefficient as when you remove an item the front pointer increments and nothing can be added before it

New cards
12

What types of ques are there

  • linear

  • circular

  • priority

New cards
13

What are data structures

Formats that are used to store large volumes of data

New cards
14

What are strong data structures

Int, string , Boolean, float, real

are base for all other data types

New cards
15

What are static data structures

Theses are data structures that are allocated a fixed amount of memory which doesn’t change throughout the program e.g Array

New cards
16

What are dynamic data structures

These are data structures whose memory allocation size can change throughout the program execution eg. Linked list

New cards
17

cons of static data structure

Inefficient as memory might be allocated but not be used

New cards
18

pros of static data structures

  • Fast access to each element of data as the location doesn’t change

  • Fixed structure making it them easier to program

New cards
19

cons of dynamic data structure

  • no fixed structure therefore making it harder to program them

  • slower access to each element of data as their location constantly changes

New cards
20

What is abstract data structure

defines data types which are defined by the operations that can be performed on them

New cards
21

What are examples of stack

  • linked list

  • stack

  • tree

  • graphs

New cards
22

What is a memory heap

a pool of memory that can be allocated to variables during program execution , used in dynamic data structure

  • allows more efficient use of memory

New cards
23

What is memory leakage

when program assigns memory to dynamic variables and never releases them causing memory from heap to run out

New cards
24

What is Garbage Collector

Checks if dynamic variable has finished using memory allocated to it and releasees it back to heap

New cards
25

What is depth first traversal

explores the entire branch before backtracking

New cards
26

What is breadth first traversal

A node is full explored before before next node is explored

New cards
27

What is the difference between breadth first search and depth first search

  • depth first search uses stack

  • breadth first search uses queue

New cards
28

What is the formula to workout angle between to vectores

cosθ= (a.b )/ |a||b|

New cards
29

What is convex combination

α*z+β*y

  • α+β=1

  • α,β >=0

New cards
30

what are pros and cons about adjacency matrix

+good for graphs with a lot of edges and few vertices

+quicker to find an edge between to nodes

-stores information about each edge connected or not

New cards
31

what are pros and cons about adjacency list

  • +good for graphs with few of edges and a lot vertices

  • +less space/ storage wasted

  • - need s to look through every edge to find if there is a connection j or not

New cards
32

What are the ways a vector can be represented

arrays, dictionaries

New cards
33

What are vectors

A vector can be represented as a list of numbers, as a function and as a way of representing a geometric point in space.

New cards
34

what can be use to represent a vector if its viewed as a function

dictionary

New cards
35

what can be use to represent a vector if its viewed as a list

1D array

New cards
36

What are all the vector notation (42,110,-5.5, 10.75)

  • list [42,110,-5.5, 10.75]

  • dictionary { 0:42 , 1:110, 2:-5.5 , 3:10.75}

  • Array[3] - myvector[0]=42 …. myvector[3]=10.75

  • function

    f: S→ R

    S={0,1,2,3,}

    0→42

    1→110…

  • R4- vector with 4 elements

New cards
37

What is a tree

A simple Connected graph ( connected, undirected graph with no cycles)

New cards
38

What is a binary tree

Each node has maximum of 2 neighbours and has root

New cards
39

What is a rooted tree

a tree which has one node designated as root

New cards
40

what is root node

a node which has no parents

New cards
41

What is recursion

a subroutine that calls its self

New cards
42

What is base case

Any recursive subroutine must meet have a stopping condition — base case ( if no base case present it will result in a stack overflow

New cards
43

What is general case

This is the bit of code which calls itself

New cards
44

What is added to stack frame during recursion

  • return values

  • local parameters

  • return addresses

  • parameter

New cards
45

Recursion stack frame

New cards
46

Compare recursion and iteration

New cards
47

Which traversal represents polish notation

Pre order

New cards
48

Which traversal represents infix notation

in order

New cards
49

Which traversal represents reverse polish notation

post order

New cards
50

Time complexity of merge sort

O(nlogn)

New cards
51

Time complexity of finding out if number is even or odd

O(C)

New cards
52

Time complexity of binary search

O (logn)

New cards
53

Time complexity of linear search

O (n)

New cards
54

What is time complexity for polynomial

O (n^k)

New cards
55

What is time complexity for bubble sort

O (N²)

New cards
56

what is time complexity of travelling tower of Hanoi

O(K^n )

New cards
57

What is the time complexity of travelling salesman problem

O ( n!)

New cards
58

What is finite state machine

A model for compuatuion for a machine that is always in one of a fixed number of states

New cards
59

What are finite state machines used for

  • robotics

  • video games

  • used to recognise languages

New cards
60

What is mealy machine

A finite state machine that determines its outputs from the present state and the inputs

New cards
61

What is turning machine

A finite state machine that controls 1 or more tapes where at least 1 is infinitely long

New cards
62

What is the transition rule of finite state machine

turning machine must have a set of instructions telling us which direction to move tape head in , which output is places onto tape based on current state

New cards
63

How do you represent turning machine as a transition function

δ( current state, input symbol )= ( next state, output symbol, movment )

New cards
64

How does a universal turning machine work

It can represent any FSM unlike turning machines are limited to 1 FSM machine so making them problem specific

  • description of the FSM to be used is read from the same tape as input data, than data is processed

  • U turning machine acts as interpreter as they read they instructions in sequence before executing operation on input data

New cards
65

why are turning machines important

  • anything a turning machine can compute a real world computer can compute , this tells us which problems are computable and which aren’t

New cards

Explore top notes

note Note
studied byStudied by 3190 people
Updated ... ago
4.5 Stars(8)
note Note
studied byStudied by 5 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 47 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 5 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 19 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 45 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 42 people
Updated ... ago
5.0 Stars(2)
note Note
studied byStudied by 16936 people
Updated ... ago
4.5 Stars(11)

Explore top flashcards

flashcards Flashcard40 terms
studied byStudied by 1 person
Updated ... ago
5.0 Stars(1)
flashcards Flashcard147 terms
studied byStudied by 85 people
Updated ... ago
5.0 Stars(2)
flashcards Flashcard49 terms
studied byStudied by 3 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard125 terms
studied byStudied by 3 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard54 terms
studied byStudied by 115 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard76 terms
studied byStudied by 7 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard132 terms
studied byStudied by 18 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard60 terms
studied byStudied by 3010 people
Updated ... ago
4.5 Stars(14)