Hi all,
I was asked this question in some interview.
I was required to write code for finding junction in a linked list (which is in form of Y with both arms not necessarily equal) for production environment in O(1) space and linear time.
I came up with this solution (which i had previously seen somewhere) :
1. Measure lengths of both l...
I am new to Sharepoint and I want to make sure I am on the right path.
I am in a highly restricted environment and would rather do this in Visual Studio but am currently in the position where I have to try to get this to work using just the web interface and Sharepoint Designer.
I have created multiple lists that I plan on using in a r...
I have a BST which is a linked list in C++. How would I delete the whole thing from memory? Would it be done from a class function?
...
My C++ program creates a binary search tree. I know how to print out the values in pre-order, post-order, and in-order.
However, I want to do something a little more difficult. I want to print out the values the way they would look if someone drew the tree on paper. It would have the root at the center at the top, it's left child rig...
My C++ program creates an unbalanced BST from user input, and saves it do disk. It does this by first indexing each node by doing a pre-order traversal and assigning each node a unique number. Next, it outputs the BST to a file. It does this by doing a pre-order traversal and then for each node printing to file the data value, the ind...
typedef struct Node
{
int data;
Node *next;
Node *other;
};
Node *pHead;
pHead is a singly linked list. The next field points to the next element in the list. The other field may point to any other element (could be one of the previous nodes or one of the nodes ahead) in the list or NULL.
How does one write a copy function that...
Hi,
I'm trying to create a linked list, I've got it working, but I'm still a little confused. I'm using the following struct:
typedef struct _MList
{
int dx;
int dy;
struct _MList *next;
} MList_t, *MList_p;
I've tested that this structure makes sense, and I've got a function to print out a list:
void mListPrint(MList_t *...
Is this a valid LinkedList destructor? I'm still sort of confused by them.
I want to make sure I'm understanding this correctly.
LinkedList::~LinkedList()
{
ListNode *ptr;
for (ptr = head; head; ptr = head)
{
head = head->next
delete ptr;
}
}
So at the beginning of the loop, pointer ptr is set to hold the add...
Does Foreach Item in LinkedList give items in strict order?
Is the strict order First=>Next=>Next=>...=>Last respected in foreach or maybe is better to use while (item != null) ... item = item.Next?
...
Hi,
I'm a programming student in my first C++ class, and recently we covered linked lists, and we were given an assignment to implement a simple one. I have coded everything but my pop_back() function, which is supossed to return a pointer to the Node that needs to be deleted in Main(). No Node deletion is to be done in the actual funct...
I have two processes and i want to share a linked list between them. One of the
processes is just going to read the list while other process is going to modify the
list ( add/delete entries). Can you tell me how to achieve it?
Let me add more details to it the language is C and the platform is Linux.
It seems that shared memory is o...
The first function reads a file that has a bunch of 'char's and puts them in a linked list. It is not working :(.
#include <stdio.h>
#include <stdlib.h>
struct list {
char val;
struct list* next;
};
typedef struct list element;
int lcreate(char* fname, element* list);
int ldelete(element* list);
int linsert(char a, char b, el...
Possible Duplicate:
How do I implement a Linked List in Java?
hi all,
I need to create linked list in java, but not from the built-in class, i want to create from the beginning.
i have created a class and when i try to manually add elements, it worked, but how to implement add(element) method so i can add element to that li...
is there anything similar to .Net's
LinkedListNode<(Of <(T>)>)..::.Next and LinkedListNode<(Of <(T>)>)..::.Previous properties in Java's java.util.LinkedList.
...
I'm not sure I fully understand how to use the LinkedList class provided with SmallTalk Visual Works. I am able to create an instance of the class by simple doing:
myList := LinkedList new.
But how do I add a node. I tried creating an instance of Link class and setting a value but it doesn't seem to be working.
myLink := Link new.
...
The method does not show any error but I am unable to use it in main method to display the list.
if (userinput.equalsIgnoreCase("push") )
{ calc.push(value);
calc.displaylist();
System.out.println(calc.getValues());
}
else if (userinput.equalsIgnoreCase("mult"))
{ calc.push(calc.mult());
ca...
int findLargest (ListNode *p)
// --------------------------------------------------------------------------
// Preconditions: list head pointer is passed as a parameter.
// Postconditions: returns the largest value in the linked list.
// --------------------------------------------------------------------------
{
if (p->item != NULL...
I'm trying to create a singly linked list from an input text file for an assignment. I'm trying to do it a little bit at a time so I know my code is not complete. I tried creating the head pointer and just printing out its value and I can't even get that to work, but I'm not sure why. I included the struct, my create list, and print l...
I'm basically trying to create a linked list from a text file and add a new member every time the words are different, and increment the count if the words are the same (hw assignment). I thought I did it correctly, but it seems to add a member no matter what. I'm wondering if I'm traversing the list incorrectly while I search? Here i...
I'm trying to print the list of a singly linked list that I referred to in link text
It works, but I do get the compiler warnings
"Initialization discards qualifiers from pointer target type"(on declaration of start = head) and return discards qualifiers from pointer target type"(on return statement) in this code (I am using XCode):
/...