Posts in Computer Science 1
Loops and Lists

Write a function called identical_indexes that takes two lists and returns a list containing the indexes into both lists where the values are identical. If there are no such values, the function should return an empty list. Be careful to not have an index out of bounds error.

Sarah S.
Trees Review

Essentially, trees are an abstraction that allow for hierarchical organization of “things”. These “things” can be anything, but when we’re learning trees they are often numbers (or letters). An abstract data type just means that it is a way of organizing data that we may use later, without care for how the abstraction is actually implemented (for example with lists, or with a class).

Henry M.
Recursion

Recursion occurs when a function calls itself. Recursion is useful when dealing with problems that have recursive properties. Consider a function factorial(n) that returns the factorial of n. This function can be defined recursively because factorial(5) = 5 * factorial(4) = 5 * 4 * factorial(3) and so on.

Eunsub L.
Generate Parentheses Problem

The problem is: Given N pairs of parentheses, write a function to generate all combinations of well-formed parentheses. The naive solution is to generate all combinations of N pairs of parentheses, then checking if each one is valid.

Eunsub L.
Makefile

Now, if you change main.c, factorial.c, or factorial.h, you would need to re-compile those files manually. This is a cumbersome process, especially when the number of files is big. The solution is to automate the compilation process by using Makefile.

Eunsub L.
Matlab Basics: Parsing Vectors in For Loops

I have a vector of a specific length that is not predetermined, and I am trying to create a new vector of only numbers divisible by 2. This must be done using for loops to parse the vector. I am going to focus on the algorithm and syntax of the for loops rather than the setup of the function itself.

Ioana D.
Pointers in C

A pointer is simply a variable that stores the address of another variable.

An address of a variable is where the variable is located in memory. For example, if you declare int n = 8; in your program, then your computer’s memory would look something like this…

Eunsub L.

A very important data structure, that is often confusing to beginning CS students, is the linked list. Linked lists are a linear data structure, just like basic arrays. However, unlike an array, the linked list is not one large, continuous block in memory. Instead, each element in a linked list contains a pointer to the next element. Each element is “linked” to the next, hence the term “linked list.”