Computer Science Problems: Pointers, Arrays, Strings, Data Structures, and Assembly, Quizzes of Computer Science

A series of problems related to various topics in computer science, including pointers, arrays, strings, data structures, and assembly. The problems cover concepts such as moore's law, c syntax and semantics, pointers and arrays manipulation, strings handling, and list reversal. Some problems also include assembly code translation and history of computing trivia.

Typology: Quizzes

Pre 2010

Uploaded on 03/28/2010

koofers-user-1sh-1
koofers-user-1sh-1 🇺🇸

10 documents

1 / 7

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Name:__________________________________________
1
Problem 1: (5 points) Short Answers (5 minutes)
a) Moore’s Law states that the number of _____________________ will double every
______________________.
b) Name the 5 classic components of a computer
c) What evaluates to TRUE in C? What evaluates to FALSE?
d) Name the 4 regions of a program’s memory space
e) What do the acronyms CISC and RISC stand for? What is the difference between the
two?
pf3
pf4
pf5

Partial preview of the text

Download Computer Science Problems: Pointers, Arrays, Strings, Data Structures, and Assembly and more Quizzes Computer Science in PDF only on Docsity!

Problem 1: (5 points) Short Answers (5 minutes)

a) Moore’s Law states that the number of _____________________ will double every

______________________.

b) Name the 5 classic components of a computer

c) What evaluates to TRUE in C? What evaluates to FALSE?

d) Name the 4 regions of a program’s memory space

e) What do the acronyms CISC and RISC stand for? What is the difference between the two?

Problem 2: (5 points) C Syntax and Semantics (5 minutes) Given the following declarations: char a[14] = “pointers in c”; char c = ‘b’; char *p1 = &c, **p2 = &p1;

State whether out any of the following 5 statements that are not correct C. If they are not correct, give the reason why.

  1. p1 = a + 5;
  2. &p1 = &a[0];
  3. p2 = a;
  4. *(a + 10) = ‘t’;
  5. *p2 = %c;

Problem 4: (20 points) Strings (15 minutes) Write a C function named substring that, given a string s , and two positions start and

finish, where 1 ≤ start < finish ≤ strlen(s) , inclusive, returns the substring corresponding

to positions start through finish. For example, substring("abcd", 2 , 4) should return the string "bcd". The insertion should not change the argument string. You must return a pointer to a new string. You don't need to do any error checking.

*char * substring (char s, int start, int finish){

Problem 5: (30 points) Data Structures (20 minutes) A list is a series of elements that are sequentially connected to each other. A list node is a structure that represents a single element of a list. A list node is formally defined as follows:

a) (5 points) On a MIPS machine with 32 bit addressing, and every word in memory must be aligned to 4 byte addressing, how many bytes does the compiler allocate for one variable ListNode?

b) (20 points) A list is simply a series of these nodes connected using pointers.

Write a C function that completely reverses the ordering of the elements in the list. Extra credit will be given if you do it using recursion.

The function should be named reverse and should take one argument: a pointer to the first ListNode object of the list. It should return a pointer to the new first element of the list (which was previously the last element)

ListNode * reverse(ListNode *aNode) {

Extra Credit: History of Computing

a) (1 point) What is the significance of the Jacquard Loom?

b) (1 point) Jeopardy: She helped Charles Babbage program his computing engines and was called the first woman programmer

Who is _________________________________?

A theoretical machine proposed in 1937 in an attempt to define the meaning of computation.

What is _________________________________?

They independently invented the integrated circuit in 1959.

Who are _________________________________?

c) (1 point) Name and describe the significance of the major concept introduced by the Von Neumann machine.