Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 22 Feb 2011
Offline Last Active Jun 14 2016 01:39 PM

Posts I've Made

In Topic: String: How to find the most common character occurrence.

22 March 2015 - 04:04 PM

I completely agree Nypyren. This is a self-imposed limitation that I am doing to test with that particular set of Unicode characters. I wanted to refine the method first, and then expand it to include a bigger character set.



In Topic: C# Linked List implementation review

09 March 2015 - 11:40 AM

@ChaosEngine: I was going to implement it as a Generic Type, but I'm never going to use it for my projects and wanted something that I could get information from quickly, for testing, which is why I pre-made it using the String class.


@Pink Horror: I' guessing that if I wanted to look at/use every item I would (internal code):

for(int i = 0; i < list.Length; i++)
     currentNode = currentNode.next;

User code:

DoSomethingWithAllListItems(int pLength);

This would be O(N) Linear as it will take an amount of time and resources proportional, to the size of the list (which if it gets very big, will cost a lot). If I want constant time, such as the change I have made to my AddNode() method, I would need to be able to access a node directly, knowing it's location beforehand.


I hope I have understood what you are trying to say, but what would be a constant alternative to looping the list. Would I have to order it first?



In Topic: C# Linked List implementation review

08 March 2015 - 04:04 PM

As an update: I went back to my AddNode method. If I use a reference (let's call it tail) which stores the final node in the list so that new nodes can be added without traversing the list.

public void AddNode(string stringIn)
            StringNode newNode = new StringNode(stringIn);

            if (IsEmpty())
                list = newNode;
                tail = list;
                tail.next = newNode;
                tail = tail.next;

What I'm struggling to understand is how my else statement works. It works, as in it adds nodes successfully. Can anyone clarify that my thought process as to what I'm doing is correct?


If the list is empty, I add the new node as the head and make the tail equal to the head (the head is both the first and last node).


If there is a node (say we are at the point that we haven't added anymore than one), then we make the tail.next (aka list.next) equal to our new node. Then we make tail equal this last node.


What I'm struggling to understand; once we exit the AddNode function, and the temp variable newNode is no longer in memory, what is preserving the references to these different nodes in memory? Only list and tail exist, I'm changing what tail points to every time I add a node to a non-empty list, how are any nodes in-between able to be referenced/not being flagged for garbage collection?


Please ask if you need anymore clarification.



In Topic: C# Linked List implementation review

08 March 2015 - 02:35 PM

Hi all,


Thanks for the feedback so far. I am implementing it to further my understanding of how they work. My intent would be to use the .NET implementation.


I did think as I was implementing the loops with indexes that what happens if the list gets too big? I know that each node is stored, non-sequentially, in memory which makes it longer to iterate over.


I have thought about adding a reference for the tail; making it the result of AddNode().


What I'm stuck on is the idea of holding a place in the list. Isn't this just as slow as starting from the beginning? If you start at the beginning then you don't have to worry about going backwards. Otherwise I need to create a doubly Linked List to be able to traverse back and forth.


I have some great feedback to work on from this.





In Topic: C# Code Snippet Review

13 January 2015 - 04:12 PM

Wow. Thanks for all the response guys. You've given me a lot to think about.


I'm actually eager to finish this chapters exercises just so I can go back to the Deck example and implement these new ideas.


When I first saw the problem, one method I kept coming up with was swapping cards, but ignoring ALL cards previously swapped. Not just the card put into the visited portion. What is the 'bias' being quoted? Is this more to do with the computation of the randomness, or the same as the randomness created during a 'human' shuffle?


My thanks,