Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1

    Default Singly links .. Unsaon ni pag suwat functions?


    write a function that would return the 5th element from the tail (or end) of a singly linked list of integers.
    for example:
    2 3 4 5 6 7 8 9 10 11
    your function would return 7
    code should return the 5th element from the tail in a single pass
    code should not use any built-in .net collection components




    2.) write a function to reverse the words in a string, for example "cat and dog" becomes "tac dna god"
    Cat and dog
    becomes
    taC dna god
    do not use any string manipulation functions that you do not implement yourself
    code should reverse each word within the string without altering whitespace characters
    code should treat punctuation chars as part of the word
    code is only required to deal with standard english chars. unicode support is not required
    should be your own code and should not use any built-in .net string manipulation calls

  2. #2
    I tried my best on the first problem..

    please check..

    Spoiler! 

    function GetFifthElement(LinkedList list){
    return ;
    }


    2nd problem pinaka lisud, try using photoshop.

    Advice lang bro, maka boang ning programming, shift nalang og lain kurso bro...
    Last edited by stealthghost; 02-25-2013 at 05:58 AM.

  3. #3
    I'm guessing that this is a school exercise?
    Quote Originally Posted by imjustap00rb0y View Post
    write a function that would return the 5th element from the tail (or end) of a singly linked list of integers.
    for example:
    2 3 4 5 6 7 8 9 10 11
    your function would return 7
    code should return the 5th element from the tail in a single pass
    code should not use any built-in .net collection components
    My idea is first, Implement your own singly linked list since you are required not to use .NET Collection components. There are a lot of examples in the internet if you take time to research it like the following:
    c# - Creating a very simple linked list - Stack Overflow
    DotNetSlackers: Generic Singly Linked List (C# Implementation)

    When you are done with your linked list. Then implement the function that would get the 5th element from tail. Since you'll be coding the linked list itself, it'll be fairly easy for you to be able to locate this node/element.

    Quote Originally Posted by imjustap00rb0y View Post
    2.) write a function to reverse the words in a string, for example "cat and dog" becomes "tac dna god"
    Cat and dog
    becomes
    taC dna god
    do not use any string manipulation functions that you do not implement yourself
    code should reverse each word within the string without altering whitespace characters
    code should treat punctuation chars as part of the word
    code is only required to deal with standard english chars. unicode support is not required
    should be your own code and should not use any built-in .net string manipulation calls
    HINT:
    A string is an array of char.
    e.g.
    string text = "Cat and dog";
    text[9] == 'g'
    text[0] == 'C'

    I hope this helps.
    Last edited by Maikeru; 02-25-2013 at 10:45 AM.

  4. #4
    Elite Member
    Join Date
    May 2011
    Gender
    Male
    Posts
    1,465
    1. baliha ang loop nya count 5
    2. baliha ra ang loop

    kinahanglan kbw kag array ani boss. Goodluck

  5. #5
    Quote Originally Posted by jairoh_ View Post
    1. baliha ang loop nya count 5
    2. baliha ra ang loop

    kinahanglan kbw kag array ani boss. Goodluck
    di lang array iyang kinahanglan.. kinahanglan sad ni sya mangitag iyang paagi og maminaw sa instructor

  6. #6
    kamo na ang graduhan ana dli na c TS hehe

    nindotag advice ni kuya @stealthghost oy hahahahah

  7. #7
    create explode function for that string

    count the arrays backward and determine 5th elements.

  8. #8
    rev string tokens

  9. #9
    maka.remember lang nuon ko sa akokng C subject before da. Data Structures to the max!

    Single Link List
    Double Link List
    Binary Tree and Traversals

    using C and your all time favorite to hate POINTERS! Hahahaha.


    Problem #1
    Single Link List, this can simply be implemented using Arrays, solutions are plenty for this one, including posted above you may have a rough algo already so no need to spoon feed there.

    Problem #2
    Reverse a string without using functions found on STRING Library or us any function you design yourself.
    -Naka.post nako ani sa una....balik2x na ni nga problem sa programming students...search pud gamay hehehe.

    Ang hint sa problem 2 kay gisulti na ni Maikeru.

    Algorithm
    1. Get input string
    2. Determine the length of the input string
    3. Display the string in reverse.
    3.a loop from the end of the string until the first character.

  10. #10
    string a= "cat and dog";return a[a.length-5];

    string s= "2 3 4 5 6 7 8 9 10 11";string n= "";for(int i=s.count;i>0;i--) { n+= str[i-1].ToString();}return n;

  11.    Advertisement

Page 1 of 2 12 LastLast

Similar Threads

 
  1. unsaon ni pag trap? para dili mag redundant,,
    By mcapon in forum Programming
    Replies: 6
    Last Post: 10-10-2010, 02:53 AM
  2. unsaon gani ni pag activate sa smart bro?
    By cobraKing in forum Computer Hardware
    Replies: 0
    Last Post: 08-10-2010, 04:25 PM
  3. Unsaon ninyo pag-salo sa gibiloin nga legacy ni francis m.
    By paulard in forum General Discussions
    Replies: 1
    Last Post: 03-12-2009, 05:23 PM
  4. NAA KO CS SOURCE, UNSAON NI CYA PAG PLAY UG LAN UG ONLINE?
    By pigotz in forum Software & Games (Old)
    Replies: 0
    Last Post: 05-06-2008, 02:46 PM
  5. unsaon man ni pag network? naglibog jud ko...
    By emc in forum Computer Hardware
    Replies: 31
    Last Post: 09-02-2005, 02:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top