1.1 2 marks] Assume a system where int variables are represented by 8-bit twos com- plement number representation. If an int

1.1 2 marks] Assume a system where int variables are represented by 8-bit two's com- plement number representation. If an int variable var1 bit representation of var1? If there is another int variable var2 38, what is the corresponding 2, what is the = var1 = corresponding bit representation of var2? 1.2 [2 marks] Assume a 16-bit floating point number representation system as described in the textbook, where the most significant bit (the left-most bit) represents the sign, the following three bits represent the exponent (of 2) with two's complement representation, and the rest of the bits represent a mantissa (with the decimal number 7.125, and what bit pattern represents the decimal number -0.25? no hidden bits). What bit pattern represents 1.3 3 marks] Suppose that you are subject to locate an integer 9 in a sorted array {1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21} Write out the elements that will be compared with the integer 9 when the binary search algorithm is executed. using the binary search algorithm as described in the 1.4 [3 marks] You are given an array of strings: char *strings [6] “cheetah”, “jaguar”, “tiger”, “leopard”, “lion”, “puma”} Write out the array after it has been converted into a max is greater than any of its child nodes) using the build_heap algorithm described in the subject. The strings in the array are compared alphabetically. heap (that is, every parent node 1.5 [4 marks] You are have a value of -1. An int typed key is inserted into the hash table using tion h(key) linked lists given an int array A of size 5 as a hash table, where empty buckets a hash func- (key 3) 5, and collisions are handled by separate chaining with key * Write out the hash table after each of the following key values has been inserted into the hash table: 1, 3, 5, 7 (you need to write out a total of 4 hash tables)



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *