Thread: fill the gaps question..

  1. #1
    Banned
    Join Date
    Oct 2008
    Posts
    1,535

    fill the gaps question..

    the following function gets as an argument two sorted linked lists
    which are sorted by value in ascending order.
    there may be nodes with equal value variable in them.

    the function merges both functions into a new one.
    in which every node has a unique value (in the value variable)(we cut the copies)

    you are not alloed to use malloc
    but you need to delete twin nodes (with the sme number in the value variable)
    fill the missing gaps

    Code:
    #define  BIG  999999999
    typedef  struct  item  item;
    struct  item {
    	int value;
    	item *next;
    }; 
    
    item *different_merge(item *l1,item *l2){
    	item *temp;
    	int v1,v2;
    
    	if(!l1 && !l2) return NULL;
    
    	if(l2 && l2->next && l2->value==l2->next->value){
    		temp= ?? 1 ?? ;
    		?? 2 ??;
    		return ?? 3 ??;
    	}	
    	if(l1 && l1->next && l1->value==l1->next->value){
    		temp=?? 4 ??;
    		?? 5 ??;
    		return ?? 6 ??;
    	}
    	
    	v1=(l1) ? l1->value:BIG;
    	v2=(l2) ? l2->value:BIG;
    
    	if(v1==v2){
    		temp=?? 7 ??;
    		?? 8 ??;
    		return ?? 9 ??;
    	}
    	if(v1<v2){
    		?? 10 ?? =?? 11 ??;
    		return ?? 12 ??;
    	}
    
    	?? 13 ??= ?? 14 ??;
    		return ?? 15 ??;
    }

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    Seriously? 1500 posts, and you start a "Do my homework" thread? You didn't even ask a question. I'd post the board's homework policy for you, but I'm sure you've seen it before...

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Why the ____ are ____ still here?

    That's my fill in the gaps question to you.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    >> fill the missing gaps

    You:

    1) continually ask for homework solutions, even though you have been instructed on numerous occasions not to do so.
    2) consistently ignore the advice of others.
    3) typically don't follow-up on replies to your questions.

    Three strikes - you're out.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  5. #5
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by Sebastiani
    Three strikes - you're out.
    I agree.

    *thread closed*
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. linked list fill the gaps question..
    By transgalactic2 in forum C Programming
    Replies: 2
    Last Post: 07-06-2009, 12:35 PM
  2. subsets filling the gaps question..
    By transgalactic2 in forum C Programming
    Replies: 0
    Last Post: 07-06-2009, 04:51 AM
  3. Replies: 3
    Last Post: 12-22-2004, 07:29 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 09:22 PM