Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 794267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T22:17:15+00:00 2026-05-14T22:17:15+00:00

typedef struct child {int count; char word[100]; inner_list*next;} child; typedef struct parent { char

  • 0
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)
  {   temp = (child *)malloc(sizeof(child));
    strcpy(temp->word,num);
    temp->count =size;
    temp->next=NULL;
    *q=temp;
  }
  else
  {  temp = *q;
   while(temp->next !=NULL)
   {  temp=temp->next;
   }
   r = (child *)malloc(sizeof(child));
   strcpy(r->word,num);
   r->count = size;
   r->next=NULL;
   temp->next=r;
  }

}

This is my append function which I use for adding an element to my child list. But my problem is it only should append unique values which are followed by a string. Which means :

Inputs :  aaa bbb aaa ccc aaa bbb ccc aaa

Append should act :

For aaa string there  should be a list like bbb->ccc(Not bbb->ccc->bbb since bbb is already there if bbb is coming more than one time it should be increase count only.)
For bbb string there should be list like aaa->ccc only
For ccc string there should be list like aaa only

I hope i could make myself clear. Is there any ideas? Please ask for further info.

What i’ve tried is checking the previous elements entered with the new element. I kinda failed it.

int search(child *p)
{
    child *temp= (child *)malloc(sizeof(child));
    int var =0;
char num[100];
temp = p;
strcpy(num,p->word);
while(temp->next!=NULL)
    {

    if(strcmp(temp->word,num)==0)
    var =1;
    temp=temp->next;
    }
return var;
}

This is what i’ve tried so far. With this search function i would control if the element is here or not. But it failed.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T22:17:16+00:00Added an answer on May 14, 2026 at 10:17 pm

    If I understand correctly, given the inputs

    aaa bbb aaa ccc aaa bbb ccc aaa
    

    You want the parent list to have 3 elements – a child list for aaa, one for bbb and one for ccc.

    The list for aaa should contain all strings that followed aaa in the original input, which here is just bbb and ccc. It should only contain them once each, with the count variable in the corresponding nodes incremented so that bbb‘s count is 2 and ccc‘s count is 1.

    Is this correct? If it is, read on.

    for every string S in your input
    {
       if S is not associated with a child list in the parent
       {
          create a new child list associated with S at the end of the parent list
       }
    
       // now we have C, the child list we either found above or created
       if there is a string S' after S
       {
          find the element S' in the child list C by iterating through it
          if you don't find the element S', create/append it with count = 1
          else when you find the element, increment its count
       }
    }
    

    I think this should get you where you want to go.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.