# Polyforms

February 26, 2014 at 2:16am
0 notes

## kartikey92.github.io →

Playing around with GitHub pages. I just might move away from tumblr. I hate posting code here; it’s too much of work and still the code does not come out well (check previous post). Plus, I’m loving the idea of doing everything through the linux terminal :D

Though, the shift won’t be immediate as I’ll have to figure out a blogging platform and a way to run it through github. Github recommends Jekyll.

February 24, 2014 at 1:39am
0 notes

## Swapping two constructors using pointers

I have been studying from Foundation of Computer Science by Jeffrey Ullman and came upon an exercise (on page 32; “Sorting Keys”).

Suppose we have a constructor STUDENT as following:

``````struct STUDENT{

int StudentID;

} A[MAX];``````

and we wish to swap two STUDENT constructors on the basis of the condition:

``A[j].StudentID < A[small].``StudentID`;`

where ‘small’ is the smallest known StudentID value till a particular iteration of a loop.

Now, one way to this would be to swap every variable of the strucute with each other. Like this:

``TempA.StudentID = A[j].``StudentID`; A[j].`StudentID` = A[small].`StudentID`; A[small].`StudentID` = TempA.`StudentID`;`

and so on for every variable in the strusture.

This will take loads of time which only increase as the number of variable in the strucutre increase.

So, the book highlights a solution to this:
"Since it is time-consuming to swap whole structures, a more efficient approach
is to use a second array of pointers to STUDENT structures and sort only the pointers
in the second array. The structures themselves remain stationary in the first array.
We leave this version of selection sort as an exercise.”

Here is an idea about how to do it..

``````STUDENT *St[MAX];

for(int j=0; j<MAX; j++) {
St[j] = &A[j];
}

if(A[i].Sal < A[0].Sal)
swap(St[i],St[0]);Where swap function is defined as:

void swap(STUDENT **A, STUDENT **B) {
STUDENT temp = *A;
*A = *B;
*B = temp;
}``````
`` ``

February 15, 2014 at 4:29pm
0 notes

## Jony Ive: Unofficial Biography

I finished reading Jony Ive’s unofficial biography by Leander Kahney few days back. Nice book. This along with Steve Job’s biography give an interesting perspective towards the products of Apple; you get to read about the story behind every product. Which is pretty romantic and unique in the consumer hardware industry. It gives every device a sense of heritage.

After the beginning, where the author talked about Ive’s childhood, schooling and british education, the book focused a lot on design in Apple during the era without Steve and for quite some time it gave a feeling that the book was more about Design at Apple rather than about Jony Ive. Though, later it did focus back on him and I guess it is important to talk about design at Apple, even the ugly part, because it gives a sense of scale to Ive’s achievement.

Jony is a likable man. He shares the same amount of Intensity, focus and desire for perfection as Steve him but does not degrade other people in the process.

Nice book. Would only recommend to people who like or are interested in Apple, design or both.

Image credits: funkyspacemonkey.com