The stack is initialized with a int MaxSize =3. Then I push one int onto the list. " Pushed:" is returned to the console. Program crashes here. I think my logic is flawed but unsure. Maybe an infinite loop or unmet condition? Thanks for your help.
I'm trying to traverse the list to the last node in the second part of the full()...
Hello,
I have implemented an insertion sort in a double link list (highest to lowest) from a file of 10,000 ints, and output to file in reverse order.
To my knowledge I have implemented such a program, however I noticed in the ouput file, a single number is out of place. Every other number is in correct order.
The number out of pla...
I have the following array structure (linked list):
struct str_pair
{
char ip [50] ;
char uri [50] ;
str_pair *next ;
} ;
str_pair *item;
I know to create a new item, I need to use
item = new str_pair;
However, I need to be able to loop through the array and delete a particular item...
I have a linked list of integers. When I insert a new Node I need to insert it not at the end, but in oder... i.e. 2, 4, 5, 8, 11, 12, 33, 55, 58, 102, etc. I don't think I am inserting it in the correct position. Do see what Im doing wrong?
Node newNode = new Node(someInt);
Node current = head;
for(int i=0; i<count; i++){
...
This was one of the interview questions asked. How to find the length of a linked list that is having cycle in it. I know how to calculate whether a linked list has a cycle or not using Hare and Tortoise technique. I even know how to calculate the length by storing the addresses in a hashset. The running time of the Algorithm should be O...
Hi
This was the question asked in interview.Can anybody help me out it in implementing in java
Given 2 linked lists(which need not have unique elements) find intersection point in the form of Y.(it can be anywhere--middle or tail)
...
I have code that looks like this:
public class Polynomial {
List<Term> term = new LinkedList<Term>();
and it seems that whenever I do something like term.add(anotherTerm), with anotherTerm being... another Term object, it seems anotherTerm is referencing the same thing as what I've just inserted into term so that whenever I try t...
For a class assignment, we can't use any of the languages bultin types, so I'm stuck with my own list. Anyway, here's the situation:
public class CrazyStructure <T extends Comparable<? super T>> {
MyLinkedList<MyTree<T>> trees; //error: type parameter MyTree is not within its bound
}
However:
public class CrazyStructure <T extend...
What's a good way to implement mutable data structures in F#? The reason I’m asking is because I want to go back and implement the data structures I learned about in the algorithms class I took this semester (skip lists, splay trees, fusion trees, y-fast tries, van Emde Boas trees, etc.), which was a pure theory course with no coding wha...
Seems that there is only doubly linked list (but no singly linked list) in the C++ standard library, right? Is there any widely-used C++ libraries with singly linked list?
...
I have a problem about Linked Lists. I already know how to create structures and linked list. But now I have to create arbitrary number of linked list which are also be kept in another structure. Which means :
struct list{int x, struct list *next; };
struct parent{int x, struct list *head, struct parent *next;}
And after lists are...
The problem appears with the insert function that I wrote.
3 conditions must work, I tested b/w 1 and 2, b/w 2 and 3 and as last element, they worked.
EDIT;
It was my own problem. I did not realize I put MAXINPUT = 3 (instead of 4). I do appreciate all the efforts to help me becoming a better programmer, using more advance and more ...
typedef struct child_list {int count; char vo[100]; child_list*next;} child_list;
typedef struct parent_list
{ char vo[100];
child_list * head;
int count;
parent_list * next; } parent_list;
As you can see there are two structures. child_list is used to create a linked list. And this list will be stored in a linked list of parent list. ...
My Struct Definitions.
typedef struct inner_list {char word[100]; inner_list*next;} inner_list;
typedef struct outer_list
{ char word [100];
inner_list * head;
outer_list * next; } outer_list;
And The problem part:
void append(outer_list **q,char num[100],inner_list *p)
{ outer_list *temp,*r;
temp = *q;
char *str;
...
If I am walking through an IEnumerable<T>, is there any way to get a new IEnumerable<T> representing the remaining items after the current one.
For example, I would like to write an extension method IEnumerator<T>.Remaining():
IEnumerable<int> sequence = ...
IEnumerator<int> enumerator = sequence.GetEnumerator();
if (enumerator.MoveNe...
typedef struct child {int count; char word[100]; inner_list*next;} child;
typedef struct parent
{ char data [100];
child * head;
int count;
parent * next; } parent;
void append(child **q,char num[100],int size)
{ child *temp,*r,*temp2,*temp3;
parent *out=NULL;
temp = *q;
temp2 = *q;
temp3 = *q;
char *str;
if(*q==NULL)
{ ...
I need to make a linked list with classes. Each list will store two values: a URI and IP. After doing all the adding, I need to be able count the total number of items in the linked list. I have tried the following code but it doesn't compile. We are not allowed to use std::list. Any suggestions please?
#include <iostream>
#include <cst...
struct Record_node* Sequential_search(struct Record_node *List, int target) {
struct Record_node *cur;
cur = List->head ;
if(cur == NULL || cur->key >= target) {
return NULL;
}
while(cur->next != NULL) {
if(cur->next->key >= target) {
return cur;
}
cur = cur->next;
}
...
I want to initialize a linked list with pointer arguments like so:
/*
* Initialize a linked list using variadic arguments
* Returns the number of structures initialized
*/
int init_structures(struct structure *first, ...)
{
struct structure *s;
unsigned int count = 0;
va_list va;
va_start(va, first);
for (s = f...
I am still new at lists in C and i got a big problem...
First i wanna show you my code for inserting item to the list:
void input_books_info(int number_of_books, BOOK *current)
{
int i;
for(i = 0; i < number_of_books; i++)
{
while(current->next != NULL)
current = current->next;
current->next = (...