2 Lists and nums Flashcards
(104 cards)
include
A growable array!
Iterator
-nested type of vector that represents position
iterator.begin() or iterator.end()
makes a pointer like object to the front or back of the vector
itr++
itr–
*itr
itr==itr
move forward
move backward
returns reference to object at itr location
true if same location
for ( vector::iterator it = v.begin();
it != v.end(); it++ )
cout «_space;*it «_space;endl;
this is the way to iteratew through aa vector with an iterator
Stacks
push
pop
top
pancakes!
7 2 3 + 8 *3+
50? I think?
Linked list?
Has every object point to the next with a next attribute as the next object
Queues
enqueue
dequeue
front()
back()
abstract data types meaning
data type without specifics about language!!
How to convert from decimal to radix?
hard to explain here is a few examples
10 from decimal to binary: 10 = 2^3 + 2^1 = 1010 or 10/2 = 5 r 0 5/2 = 2 r 1 2/2 = 1 r 0 1/2 = 0 r 1
So 1010
30 from decimal to base 5: 30/5 = 6 r 0 6/5 = 1 r 1 1/5 = 0 r 1 so 110
Convert from radix to decimal?
110 from base 5 to decimal
15^2 + 15^1 + 0*5^0 = 30
1010 = 2^3 + 2^1 = 10
How many hex digits is a byte?
2
How many bits is a byte?
8
Boolean math 0+0 0+1 1+0 1+1
0+0 = 0
0+1 =1
1+0 =1
1+1=0 carry 1
Unsigned int
no sign, 0 up to some number
a type can hold?
2^n -1 where n is number of bits
Switching endian-ness means what?
Swapping the BYTES!
0xdeadbeef is big endian.
Whats little endian form of this?
0xefbeadde
1111 0101 0000 1010
to little endian?
0000 1010 1111 0101
Point of two’s compliment?
to avoid two representations for zero
To find two’s compliment of a number with n-bit memory space.
-Zero is n 0s
-Positive numbers:
-Max vlue is 2^n-1 -1
-Sign bit is zero
-This, zero is a “positive”
number! (and is all zeros)
-Negative numbers:
-max value is -2^n-1
-take the absolute value and encode it t binry
-flip ALL the bits
-add 1 (if 0101 then 0110)
Overflow
like adding 1 to 0111 1111 (OR 127)… which is 1000 0000, which is -128.
-need more bits to make sure max value isn’t hit!
Int range vs unsigned int
-2^31 to 2^31 -1 is int
0 to 2^31 -1 is unsigned int