This content is password protected. To view it please enter your password below:

 

Here is some text

A picture!

P1140405  More text here too

 

And some more text

Yay blogging

I am studying to take my insurance licensing exam for the second time :-p and I thought hey why not write some entries about the insurance stuff I learn.  Hopefully I may learn the material better if I try to summarize all the rules in my own words and make them a little bit more riveting for my readers.  Hopefully you all will learn something and not fall asleep :D.  Tune in tomorrow for the first post(s)!

I wrote this up in an email to myself a while ago but I figure I’ll post it up here too.  A very common programming interview question is how to reverse a singly linked list.  I’ve gotten this in two interviews and also in an algorithms problem set once.

Here are my solutions, both an iterative and a recursive approach.  I think I’ve tested both out pretty well  but please do let me know if you break either one 🙂 .  Also, I use a class called ZNode which is just an ordinary node class, just cooler because it has a “Z” in it.

Iterative:
basically go from head to end, reversing as you go by using 3 pointers to: theHead, revHead, and hold (actually the names are pretty arbitrary).  

//Iterative
        ZNode reverseIter(ZNode head)
	{
		ZNode theHead = head;
		if(theHead.getNext() == null)
		{
			return theHead;
		}
		ZNode revHead = theHead.getNext();
		ZNode hold = revHead;

		while(hold != null)
		{
			hold = hold.getNext();
			revHead.setNext(theHead);

			//set the next of the head of the list to null
			if(theHead == head)
			{
				theHead.setNext(null);
			}

			theHead = revHead;
			revHead = hold;
		}
		return theHead;

	}

Recursive:
Start at the head and keep going until you hit the end, then go backwards setting each node’s next field to its parent.  Each recursive call has the parameters: head, parent, and revHead (the head of the new reversed list) 

//Recursively
	ZNode reverse(ZNode head)
	{
		return reverseHelper(head,null,null);
	}

	ZNode reverseHelper(ZNode head, ZNode parent, ZNode revHead)
	{
		if(head.next == null)
		{
			head.setNext(parent);
			revHead = head;
			return revHead;
		}
		else
		{
			revHead = reverseHelper(head.getNext(),head, revHead);
			head.setNext(parent);
			return revHead;
		}
	}

 

Dialga on the Spear Pillar in 3D

Dialga on the Spear Pillar in 3D

 

 

I just caught Dialga, one of the main legendaries of Pokemon Diamond, with a Quick Ball (a pokeball that works well if used in the first 5 turns of battle) on the first turn without doing any damage to it!  It was like I just used a Master Ball.  Okay end of extremely dorky post.

Testing this out by posting this now since I just posted a bunch of things were I modified the publish date to a date in the past.  I might have to import them all again manually.

Pictures: http://picasaweb.google.com/ChrisWKwan/NewYork010609Fb?feat=directlink

  • 3 roommates had left room already when we woke up
  • Breakfast at Grand Central Station (almond pastry, Citrus Naked juice, Orangeade Snapple for bus ride home)
  • Walked with Nate to his bus stop
  • Nate leaves
  • Simon and Chris go to Columbus Circle
  • Look for CNN building but cannot find it
  • Go to the mall – very nice, two large statues of very large people
  • Interesting art gallery on 2nd floor – a picture of an xray of a tractor and a man riding it
  • Samsung Experience: screens under glass, camera overhead tracks the movements of your hands over the glass so you can navigate around a map of the city
  • Samsung store has nice coaches and displays
  • Cartoon network store
  • Train back to Penn Station to get on corner near Tick Tock diner for Bolt bus
  • Chris gets on the Bolt bus to go back home to Boston.
  • Chris is home!

Pictures: http://picasaweb.google.com/ChrisWKwan/NewYork010509Fb?feat=directlink

  • All 3 new hostel roommates checked out in a loud ruckus early in the morning
  • Bottle of water + pieces of peanut crunch Clif bar for breakfast
  • Wating for tour had brunch at Zaro’s Bakery in Penn Station (everything bagel toasted with scallion cream cheese)
  • Madison Square Garden tour: met a Knicks dancer, sat in a skybox suite, saw some Pitssburgh Penguins on ice practicing
  • Rockefeller for NBC studio tour: saw nightly news with Brian Williams set, sat in SNL seats, saw the set!, saw make up video, saw people do a fake news cast
  • New York Public Library – had a big museum and nice reading area
  • Bryant Park – “derelict park? becomes urban oasis” – skating rink on top of fake grass and Canadian bar called “Celsius”
  • Walked around Chinatown
  • Dumplings and tea at dumpling house for lunch ($4 total, 16 dumplings, 25 cents each)
  • Simon leaves to Battery park to retrieve backpack (his New York pass was different number than we thought! – now he has two! (we cancelled someone elses :-p) )
  • Walked around Chinatown / Little Italy with Nate
  • Dinner at Da Nico (Pizza with roasted red peppers, artichokes, mushrooms, prociutto, and veal lightly breaded butterfly cut with vegetables and a side of fetticini alfredo
  • Free desert: mini fried dough with powdered sugar
  • Times Square for Planet Hollywood (finally got that shot glass)
  • Walked on the red steps on top of TKTS
  • M&Ms store
  • Hersheys store
  • Train to Columbus Circle, nice circle area with lighted benches and skateboarders, CNN building in area, nice little area in the city, skateboarder sounds almost soothing like waves crashing into the shore
  • Back home to hostel, stopped at CVS for Fuze Black and Green tea with Acai berry and Duane Reade for Haribo Happy Cola gummies (Ted’s favorite)
  • 2 new roommates in hostel (1 was actually there the night before so he probably didn’t check out)
  • In lounge settling spreadsheet (bill)
  • Writing this log while watching “Destroyed In Seconds” on the Discovery channel.

Pictures: http://picasaweb.google.com/ChrisWKwan/NewYork010409Fb?feat=directlink

  • Shower in morning, bathroom is kind of eeeew + traffic jam in room in the morning with everyone trying to get ready
  • Breakfast at Whole Foods (vegan blueberry muffin and Odwalla Mo’Beta)
  • Sports Museum of America (in Battery park)
  • Had a little bit about each of the major sports
  • Has the original Heisman trophy
  • Bought Olympic pins, Heisman trophy pin
  • West Side, saw “Friends” apartment and Central Perk coffee shop building
  • Lunch at Isle Thai Cooking (spicy basil udon with beef, Simon got Tamarind (a fruit) crispy chicken)
  • Walk through Central Park to Metropolitan Museum of Art
  • The Met was closing so we got in for free :-p
  • Met with Abhishek at Madison Square Garden for Knicks vs. Celtics
  • Knicks win 100 to 88 😦
  • Wander looking for dinner, see Korea Way – filled with expensive Korean restaurants
  • Ate a Martinique Cafe (48hr chicken barbeque with mashed potatoes)
  • Future place to go to: Red Mango ice cream? on Korea Way
  • Abhishek leaves back for Princeton
  • Walk to Times Square for Planet Hollywood.  Because Simon spent $10.84 on a mug, I got to get an $18 hat for $10 (and thus free with New York pass) with a dragon on it!

Pictures: 

  1. http://picasaweb.google.com/ChrisWKwan/NewYork010309P1Fb?feat=directlink
  2. http://picasaweb.google.com/ChrisWKwan/NewYork010309P2Fb?feat=directlink
  • Austrialian guys checked out at 10am
  • Hostel shower (bathroom is in our room) is either very hot or very cold
  • Lunch at 12pm at Ramen House? (spicy miso ramen with pork, corn, bean sproats, eggs, seaweed)
  • Got replacement NBC studio tour tickets but missed our 1:15pm show
  • Bought tickets to Top of the Rock – great view – Nate and Simon said its better than Empire State view
  • Rockefeller Center Tour – learned lots about Rockefeller and artwork there
  • Shopping on 5th Ave: Nintendo World/Pokemon Center (bought small green Yoshi plushie), NBA store, Trump Tower, Sony Experience (closed), FAO Schwartz, Apple Store
  • Dinner at Joe’s Shanghai (top recommended NY restaurant on Trip Advisor) (seew long bow, chao neen gou, meatballs (lion head))
  • Times Square for Madame Tussauds and Planet Hollywood (got a mug)
  • Empire State building skyride – so corny/lame – narrated by Kevin Bacon, “blue energy”, went into space
  • Empire State building for night view – nice city lights, very windy
  • Whole Foods for Odwalla Mo’Beta
  • Nathan’s Hot Dogs for a hot dog for Nate
  • 3 new roommates at hostel.
  • Hostel common room for internet, planning and SNL on tv