Showing posts with the label CS

The Skyline Problem

Lab3.2 The Skyline Problem
The skyline problem is defined as given n rectangular buildings in a 2-dimensional city, compute the skyline of these buildings, eliminating hidden lines. The main task is to view buildings from a side and remove all sections that are not visible. All buildings share common bottom and every building can be represented by triplet (Left, Height, Right)

As an example, if the buildings array is
[ [1, 11, 5], [2, 6, 7], [3, 13, 9], [12, 7, 16], [14, 3, 25], [19, 18, 22], [23, 13, 29], [24, 4, 28] ] then the skyline is
[[1, 11], [3, 13], [9, 0], [12, 7], [16, 3], [19, 18], [22, 3], [23, 13], [29, 0]]

Finding the Odd Occurrences of a Number

Lab3.1 Finding the Odd Number of Occurrence
You are given a sorted list of numbers where one number appears odd number of times. All other numbers appear even number of times. You are required to design an efficient algorithm to find the number that appears odd number of times. I'm using the Use Divide and Conquer method which runs at $\Theta(\log(n))$

As an example, if the sorted list is
[1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 5, 5, 6, 6] then the odd occurrence number is 2

Reverse a Nested List Recursively

Lab2.2 Reverse a Nested List Recursively
You are expected to write a python program to reverse a list which may have nested lists within it. The number of nesting levels is not limited.

As an example, the reversed list of
[1, 2, [31, 32], 4, [51, [521, 522], 53], 6] will be
[6, [53, [522, 521], 51], 4, [32, 31], 2, 1]

Find Maximum Number in a Nested List Recursively

Lab2.1 Find Maximum in a Nested List Recursively
You are expected write a recursive python function to find the largest number within a given list. The list may contain numbers and strings and, you are expected to ignore the strings. In addition, the list may be a nested list with several nesting levels and you are expected to consider the numbers in all the nesting levels.


DDR3 and DDR4 RAM???
Once I was wondering what is the difference between DDR3 RAM and DDR3L RAM. Since there is a newer DDR4 RAM available nowadays, why there's another DDR3 RAM? Later I found out that it was designed to overcome performance issues with motherboards and processors.

I was wondering why all the leading memory manufacturing companies came up with a DDR3L. Basically DDR3 and DDR4 RAM notches are not identical. So you can't fit both RAMs in the same motherboard. But hey what if the current RAM you have is not enough or not fast enough? With current motherboard and processor limitations, the maximum speed a DDR3 RAM can work is 1600 MHz. But a DDR4 RAM can work at a speed starting from 2133 MHz.

Programming Assignment 2

Python Programming Assignments
This is the second set of python assignments I found.

Python Laboratory Excersices

L1_2.2 Python Programs
Step 1: Type the Python program using a text editor such as gedit or vi or emacs or Kwrite and save as ($ gedit
Step 3: Modify the above program to display the source code.

# Step 1# ******** ## display Hello Worldprint"Hello world !\n"# Step 3# ******** #print"# display Hello World\n"print"print \"Hello world !\\n\"\n"

Star Patterns in C

Two pyramids in two for loop
When using two for loops separately inside the main for loop to create this pyramid, it takes a lot of memory and time to compile. So it is efficient in every way to use only one for loop and an if statement inside the main for loop.
Output :
* ** *** **** *** ** *

Bubble Sort

Bubble sort, sometimes referred to as sinking sort, is a simple sorting algorithm that works by repeatedly stepping through the list to be sorted, comparing each pair of adjacent items and swapping them if they are in the wrong order. The pass through the list is repeated until no swaps are needed, which indicates that the list is sorted. The algorithm gets its name from the way smaller elements "bubble" to the top of the list. Because it only uses comparisons to operate on elements, it is a comparison sort. Although the algorithm is simple, it is too slow for practical use, even compared to insertion sort.