Fundamentals of Computer Science (CSc 101) Expected Outcomes


The student will be able to:

GENERAL
  1. Explain general computing topics:
    1. the fundamental hardware and software components of a computer system.
    2. the process of high level language translation and execution.
    3. the historical trends in the economics of software development. (Hardware gets cheaper, software gets more expensive).
  2. Understand the social and ethical responsibilities of the software professional.
PROBLEM SOLVING
  1. Follow a systematic process to develop a complete program:
    1. Analyze a problem statement to identify the key elements: informational requirements (what data is transformed), and functional requirements (what it does).
    2. Create the high level design of a solution to a problem using functional decomposition.
    3. Write a low level design of a solution using a language independent notation for representing an algorithm such as pseudocode, N-S diagram, PDL, etc.
    4. Perform an algorithm walkthrough (using pencil and paper). (Also known as a code trace, desk check, or execution trace).
    5. Translate the algorithm into programming language statements following a coding standard.
  2. Follow a simple but systematic design recipe to develop a working function:
    1. Decide how to represent the problem data using the values present in the system.
    2. Identify the inputs and outputs of the function (number and kind, including conditions on the inputs and outputs).
    3. Provide a Purpose Statement summarizing the operation of the function succinctly.
    4. Provide examples of the correct behavior of the function.
    5. Represent these examples as test cases that can be run automatically.
    6. Define the function, following the structure of the input data.
    7. When necessary, decompose complex programs into simpler programs, following this recipe for each sub-component.
    8. Test the solution against the given examples.
    9. Detect, isolate, and correct defects in the implementation.
  3. Know and apply general problem solving techniques: abstraction, stepwise refinement, decomposition, modularization, incremental implementation, fault isolation, etc.
  4. Use appropriate operating system commands and utilities for software development (editor, compiler, file manipulation commands). Be able to enter source code in a high level programming language, and carry out the steps necessary to compile and execute it on a specific computer.
SIMPLE DATA
  1. Identify and know the definition of all of the primitive data types provided by the language: integers, floating-point numbers, booleans, characters, strings -- the operations that can be performed on them, and how to select the most appropriate one to represent a data item in a problem.
  2. Understand how the limited numeric precision of the computer can affect calculations.
  3. Design and implement programs that operate sequentially on primitive data.
  4. Design and implement programs that use simple and nested conditional expressions/statements to distinguish categories of input.
  5. Design and implement algorithms containing expressions that use (evaluate) the value returned by a value-returning subprogram, or “helper function”.
  6. Understand boolean functions can be used to control conditionals and also as values.
COMPOUND DATA:
  1. Understand that compound data/structures/tuples/objects encapsulate multiple values as a single value.
  2. Design and implement compound data definitions to represent compound values.
  3. Be able to construct compound values, and extract their fields.
  4. Design and implement programs that operate on compound values.
SEQUENCES:
  1. Be familiar with the data structures that a language provides to model sequences (array, table, list, etc.).
  2. Be able to use basic sequence operations: create, read, mutate.
  3. Design and implement algorithms that use count-controlled loops:
    1.  map-like functions that convert one sequence into another.
    2.  filter-like functions that return a subsequence of the given sequence.
    3.  fold-like functions that accumulate a value by traversing a sequence.
  4. Design and implement algorithms that use event-controlled loops:
    1. search-like functions that halt a traversal when reaching a given element.
  5. Design and implement functions that accept sequences as input.
INPUT/OUTPUT:
  1. Be able to use basic output operations (write to console, write to file).
  2. Be familiar with input operations reading from sequential text files or a console.
  3. Be able to perform rudimentary parsing (extract a number, split on spaces) on strings
  4. Design and implement programs that loop over input sequences.
ABSTRACTION
  1. Identify redundancies in a design that lend themselves to modularization, and to identify modules of a design that may be reused from an independently developed design.


C and Python examples of selected outcomes.  (ToDo: Fix code formatting)


#7,8,9
#include 

int main(void)
{
int side;
float radius;
char letter;

printf("Enter circle radius (float): " );
scanf("%f", &radius);
printf("Enter square side (integer): ");
scanf("%d", &side);
// NB: Strings aren't a basic type in C
printf("Enter a letter: ");
// NB: space required before %c to gobble newline
scanf(" %c", &letter);

int cube = side * side * side;
float sphere = 4/3.0 * 3.14 * radius * radius * radius;

printf("Cube: %d\n", cube);
printf("Sphere: %.2f\n", sphere);
printf("Letter: %c\n", letter);
return 0;
}
radius = input("Enter circle radius (float): ")
side = input("Enter square side (integer): ")
word = raw_input("Enter your name: ")

cube = side * side * side
sphere = 4/3.0 * 3.14 * radius * radius * radius

print "Cube: ", cube
print "Sphere: ", sphere
print "Name: ", word



10.  Selection

#include 

main()
{
float celsius, faren;

printf("Enter celsius temperature: ");
scanf("%f", &celsius);
faren = celsius * 9.0 / 5 + 32;
printf("Converted to fahrenheit is %.2f\n",faren);


if (faren > 212)
{
printf ("Steam");
}
else if (faren > 112)
{
printf ("Very Hot Water");
}
else if (faren > 32)
{
printf ("Water");
}
else
printf ("Ice");
printf("\n");
return 0;
}


celsius = input("Enter a celsius temperature ")
faren = celsius * 9.0 / 5 + 32
print "Converted to fahrenheit is ",faren
if faren > 212:
print "Steam"
elif faren > 112:
print "Very Hot Water"
elif faren > 32:
print "Water"
else:
print "Ice"


Iteration


for(i=0; i < 10; i++)
{
printf (“%d”, i)
}


int max = 10;
int x = 1;
while (x < max)
{
printf (“%d”, x);
x = x + 1;
}

 for y in xrange(1,11):
print x



max = 10
x = 1
while x < max:
print x
x = x + 1


19 (c).

#include

int sumEvens(const int list[], int size)
{
int total = 0;
int i;
for(i=1; i<size; i++)
{
if(list[i] % 2 == 0)
{
total += list[i];
}
}
return total;
}

int main(){
int a[10] = {1,2,3,4,5,6,7,8,9,10};
int sum = sumEvens(a,10);
printf("Sum: %d\n",sum);
return 0;
}
def sumEvens(mylist):
""" Return the sum of the even numbers in a list """
total = 0
for num in mylist:
if num % 2 == 0:
total += num
return total

print (sumEvens([1,2,3,4,5,6,7,8,9,10]))


Ha! There’s a defect in the C version, did you catch it?


19 (a).

#include

void addLists(const int list1[], int size1, const int list2[], int size2, int result[])
{
int i;
if (size1 == size2)
{
for(i=0; i<size1; i++)
{
result[i] = list1[i] + list2[i];
}
}
}

int main(){
int first[10] = {1,2,3,4,5,6,7,8,9,10};
int second[10] = {1,2,3,4,5,6,7,8,9,10};
int result[10];
addLists(first, 10, second, 10, result);
int i;
for(i=0; i<10; i++)
{
printf("%d ",result[i]);
}
return 0;
}
def addLists(list1, list2):
""" Add corresponding items in two lists """
result = []
if len(list1) == len(list2):
for num in range(1, len(list1)):
result.append(list1[num] + list2[num])
return result

first = [1,2,3,4,5,6,7,8,9,10]