How to use circular linked list in pl/sql?

Hi all,
how to use the circular linked list on pl/sql programming.
thanks in advance
Rgds,
B@L@

d balamurugan wrote:
Hi,
I needed this concept for the below example
TABLE_A have the columns of
ID COL_1 COL_2 COL_3 COL_4 COL_5 COL_6 COL_7
1....Y.........N........N.........Y........ N........N........ N
2....N.........N....... N.........Y.........N........N.........Y
in the above data
for id 1 i will need to take the value for COL_4, then i will check the next availability of Y through out through out the remaining columns, so next availability is on COL_1 so, i need to consider COL_4 which already Y and also i need to consider COL_5, COL_6, COL_7 as Y.
for id 2 if i need COL_7 then i need to come back on circular way and need to check the next availability of Y and need to take the columns having N before the next availability of YAnd... even after all that description... you haven't given any indication of what the output should look like.
Taking a wild guess on my part... something like this would do what you appear to be asking...
SQL> ed
Wrote file afiedt.buf
  1  with t as (select 1 as id, 'Y' as col1, 'N' as col2, 'N' as col3, 'Y' as col4, 'N' as col5, 'N' as col6,'N' as col7 from dual union all
  2             select 2, 'N', 'N', 'N', 'Y', 'N', 'N', 'Y' from dual)
  3  --
  4  -- END OF TEST DATA
  5  --
  6  select id
  7        ,rcol
  8        ,case when instr(cols,'Y',rcol+1) = 0 then instr(cols,'Y')
  9              else instr(cols,'Y',rcol+1)
10         end as next_Y_col
11  from   (select id, rcol, col1||col2||col3||col4||col5||col6||col7 as cols
12          from t, (select &required_col as rcol from dual)
13          where id = &required_id
14*        )
SQL> /
Enter value for required_col: 4
old  12:         from t, (select &required_col as rcol from dual)
new  12:         from t, (select 4 as rcol from dual)
Enter value for required_id: 1
old  13:         where id = &required_id
new  13:         where id = 1
        ID       RCOL NEXT_Y_COL
         1          4          1
SQL> /
Enter value for required_col: 7
old  12:         from t, (select &required_col as rcol from dual)
new  12:         from t, (select 7 as rcol from dual)
Enter value for required_id: 2
old  13:         where id = &required_id
new  13:         where id = 2
        ID       RCOL NEXT_Y_COL
         2          7          4
SQL>If that's not what you want... then it's time you started learning how to ask questions properly.

Similar Messages

  • Help Implementing a queue as a circular linked list...

    I have a set of code that I need to implement a circular linked list into, but I am not sure how to approach it at all. If anyone can point me to some pseudo code or sample code that I can modify for my use, that would be great.
    I created a Class CircularQueue, which implements Queue, I just need to figure out how to write it.
    Heres the code I have:
    Queue Interface
    public interface Queue<ElementType> {
         public void enqueue(ElementType e);
         public ElementType dequeue();
         public ElementType front();
         public boolean isEmpty();
    Data Holder
    public class DataHolder<ElementType> {
         // instance variables
         private ElementType _data;
          * Constructor for objects of class DataHolder
         public DataHolder() {
              _data = null;
         public void setContents(ElementType anItem) {
              _data = anItem;
         public ElementType getContents() {
             return _data;
    DeqeueButton
    import javax.swing.*;
    import java.awt.event.*;
    public class DequeueButton extends JButton {
        // instance variables
        private Queue<SmartRectangle> _queue;
        private QueuePanel _queuePanel;
         * Constructor for objects of class DequeueButton
        public DequeueButton(QueuePanel aQueuePanel) {
            super("Dequeue");
            _queuePanel = aQueuePanel;
            _queue = aQueuePanel.getQueue();
            this.addActionListener(new DequeueButtonListener());
        private class DequeueButtonListener implements ActionListener {
            private final int MOVE_LENGTH = 25;    // square size + 5
            public void actionPerformed(ActionEvent e) {
                _queue.dequeue();   // remove item from queue
                _queuePanel.repaint();
    EnqueueButton
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class EnqueueButton extends JButton {
        // instance variables
        private Queue<SmartRectangle> _queue;
        private QueuePanel _queuePanel;
         * Constructor for objects of class EnqueueButton
        public EnqueueButton(QueuePanel aQueuePanel) {
            super("Enqueue");
            _queuePanel = aQueuePanel;
            _queue = _queuePanel.getQueue();
            this.addActionListener(new EnqueueButtonListener());
        private class EnqueueButtonListener implements ActionListener {
            private int _nextX, _nextY;
            private final int SQUARE_SIZE = 20;
            private final int MAX_X = 550;
            private final int MAX_Y = 350;
            private Color _currentColor;
            public EnqueueButtonListener() {
                _currentColor = Color.BLUE;
                _nextX = MAX_X;
                _nextY = MAX_Y;
            public void actionPerformed(ActionEvent e) {
                _queue.enqueue(new SmartRectangle(_nextX, _nextY, SQUARE_SIZE, SQUARE_SIZE, _currentColor, _queuePanel));
                this.changeColor();
                _nextX -= (SQUARE_SIZE+5);  // location of next square in line
                if (_nextX < 0)     // if we reach edge of window, wrap
                {   _nextY -= (SQUARE_SIZE+5);
                    _nextX = MAX_X;
                if (_nextY < 0)     // start over
                    _nextY = MAX_Y;
                _queuePanel.repaint();
            public void changeColor() {
                if (_currentColor == Color.BLUE)          
                    _currentColor = Color.RED;
                else if (_currentColor == Color.RED)      
                    _currentColor = Color.GREEN;
                else if (_currentColor == Color.GREEN)    
                    _currentColor = Color.YELLOW;
                else if (_currentColor == Color.YELLOW)   
                    _currentColor = Color.BLACK;
                else if (_currentColor == Color.BLACK)    
                    _currentColor = Color.BLUE;
    FrontButton
    import javax.swing.*;
    import java.awt.event.*;
    public class FrontButton extends JButton {
        // instance variables
        private Queue<SmartRectangle> _queue;
        private QueuePanel _queuePanel;
         * Constructor for objects of class DequeueButton
        public FrontButton(QueuePanel aQueuePanel) {
            super("Front");
            _queuePanel = aQueuePanel;
            _queue = aQueuePanel.getQueue();
            this.addActionListener(new FrontButtonListener());
        private class FrontButtonListener implements ActionListener {
            public void actionPerformed(ActionEvent e) {
                SmartRectangle rectangle = _queue.front();    // remove item from queue
                SmartRectangle displayRect = _queuePanel.getDisplayFrontRect();
                if (rectangle != null)
                    displayRect.setColor(rectangle.getColor());
                _queuePanel.repaint();
    QueueApp
    import javax.swing.*;
    import java.awt.*;
    public class QueueApp extends JFrame
         * Constructor for objects of class QueueApp
        public QueueApp(String title)
            super(title);
            this.setSize(600,450);
            this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            QueuePanel queuePanel = new QueuePanel();
            javax.swing.JPanel buttonPanel = new JPanel(new FlowLayout());
            buttonPanel.add(new EnqueueButton(queuePanel));
            buttonPanel.add(new DequeueButton(queuePanel));
            buttonPanel.add(new FrontButton(queuePanel));
            this.add(queuePanel, BorderLayout.CENTER);
            this.add(buttonPanel, BorderLayout.SOUTH);
            this.setVisible(true);     
        public static void main (String [] args)
            QueueApp app = new QueueApp("Queues at work: Object Oriented implementation.");
    QueuePanel
    import javax.swing.*;
    import java.awt.*;
    public class QueuePanel extends javax.swing.JPanel {
        // instance variables
        private Queue<SmartRectangle> _queue;
        private SmartRectangle _frontRect;
         * Constructor for objects of class QueuePanel
        public QueuePanel() {
            super();
            _queue = new CircularQueue<SmartRectangle>();
            _frontRect = new SmartRectangle(50,50,20,20,Color.WHITE, this);
       public Queue<SmartRectangle> getQueue() {
           return _queue;
       public SmartRectangle getDisplayFrontRect() {
           return _frontRect;
       public void paintComponent(Graphics aBrush) {
           super.paintComponent(aBrush);
           Graphics2D aBetterBrush = (Graphics2D) aBrush;
           Queue<SmartRectangle> tempQueue = new CircularQueue<SmartRectangle>();
           if (_frontRect.getColor() != this.getBackground())
               _frontRect.fill(aBetterBrush);
           while (!_queue.isEmpty()) {       // remove and display contents
               SmartRectangle rectangle = _queue.dequeue();
               rectangle.fill(aBetterBrush);
               tempQueue.enqueue(rectangle);
           while (!tempQueue.isEmpty()) {    // put contents back into _queue
               _queue.enqueue(tempQueue.dequeue());
           _frontRect.setColor(this.getBackground());
    SmartNode
    public abstract class SmartNode<ElementType> {
         public abstract boolean isEmpty();
         public abstract SmartNode<ElementType> dequeue(DataHolder<ElementType> aHolder);
         public abstract void front(DataHolder<ElementType> aHolder);
         public void enqueue(ElementType anItem){}
         public void setNext(SmartNode<ElementType> aNode) {
         }  // override as needed
         public void setPrev(SmartNode<ElementType> aNode) {
         }  // override as needed
    SmartRectangle
    import javax.swing.*;
    import java.awt.*;
    import java.awt.geom.*;
    public class SmartRectangle extends Rectangle2D.Double {
        // instance variables
        private JPanel _panel;
        private Color _color;
         * Constructor for objects of class SmartRectangle
        public SmartRectangle(int x, int y, int aWidth, int aHeight, Color aColor,
                              JPanel aPanel) {
            super(x, y, aWidth, aHeight);
            _panel = aPanel;
            _color = aColor;
        public void setLocation (int x, int y) {
            this.setFrame(x, y, this.getWidth(), this.getHeight());
        public Color getColor() {
            return _color;
        public void setColor(Color aColor) {
            _color = aColor;
        public void fill(Graphics2D aPaintBrush) {
            Color savedColor = aPaintBrush.getColor();
            aPaintBrush.setColor(_color);
            aPaintBrush.fill(this);
            aPaintBrush.setColor(savedColor);
    }

    > Yea I think I understand the concept of it, but I
    dont know what the code is supposed to look like.
    Showing you what the code is supposed to look like would be effectively giving you the answer, which kind of defeats the purpose of "extra credit". Have you tried anything so far? Post what you've got, and we can give you hints on how to work through it. I thought some of the descriptions here were very explicit hints, but if you need some additional guidance, let us know your specific questions (other than "show me the code").
    Good luck!
    ~

  • Recursion using a linked list

    I am confused at how to make a linked list using recursion. I've been looking at the syntax and examples from the web for the past couple hours, but all seem to be based on an empty .java file. I need to put it in my code somehow. here's the code segment:
    public static boolean RecursiveTest (String s, int start, Node n) {
    // The linked list
    Node<char> bracket = new Node<char>();
    int size = s.length();
    char v = s.charAt(start);
    //String sElement = parens.top();
    boolean isGood = true;
    // ending "ifs"
    if (size == 0) { System.out.println("empty string");  return false; }
    if (start == size) return isGood;
    if (s.charAt(start) == '(' || s.charAt(start) == '[' ||
              s.charAt(start)== '{') {
    v.Push(sChar);
    System.out.println(sChar);
    return RecursiveTest(start+1, s.charAt(start));
    else if (sChar.equals(")") && sElement.equals("(")) {
    parens.Pop();
    System.out.println(sChar);
    return RecursiveTest(start+1);
    else if (sChar.equals("]") && sElement.equals("[")) {
    parens.Pop();
    System.out.println(sChar);
    return RecursiveTest(start+1);
    else if (sChar.equals("}") && sElement.equals("{")) {
    parens.Pop();
    System.out.println(sChar);
    return RecursiveTest(start+1);
    else if (sChar.equals(")") && !sElement.equals("(")) {
    System.out.println("bad");
    isGood = false;
    return isGood;
    else if (sChar.equals("]") && !sElement.equals("[")) {
    System.out.println("bad");
    isGood = false;
    return isGood;
    else if (sChar.equals("}") && !sElement.equals("{")) {
    System.out.println("bad");
    isGood = false;
    return isGood;
    else return RecursiveTest(start+1);
    } // end of RecursiveTest
    I'm passing a string, 0, and a new node (i dunno about the last one there), from an above main class.
    This code is wrong, i know, but it's all I got done so far. How would I be able to make a linked list inside this method?

    No one knows how to do a linked list inside a recursive method?Yes we do, but you have to realize that a list (whether it be a linked list
    or an array list or whatever) has nothing to do with recursion per se.
    If that list has to keep track of some state it certainly mustn't be created
    within that recursive method as a local variable. And (see my previous
    reply), what do you need recursion for? Counting and pairing brackets
    can easily be done using an iterative method where the list keeps track
    of the last seen left bracket (of any type).
    kind regards,
    Jos

  • How to use the Pull List in Discrete Scenario?

    Hi Gurus,
    I am using pull list MF60 in REM.
    How to use the Pull List for creating material reservations in Discrete Scenario also?
    Anyone used this Pull list in discrete, pl share.
    How is helpful in discrete scenario?
    Srini

    Hello,
    You can use Pull list for st.location transfers, if you are into WM managed then this pull list used a lot.
    You can use the pulllist to the max. extent. But with IM managed plant the use is limited and this is used only for storage location transfers.
    Issue cannot be done for Production orders. You can bring the materials to the req. storage locations and after that you have issue in the order or manually for the order.
    Regards,
    Manick.

  • Circular Linked List

    Hello,
    I am working with circular linked Lists. Now the thing is that my assignment was to make this. I had to write a set of methods. Now the thing is that I had to write a method that removes the last value. I made it but it doesnt wark and also i am confused
    public Object removeFirst()
             if(size()==0)
                return "empty list";
             Object temp = last.getNext().getValue();
             last.setNext(last.getNext().getNext());
             size--;
             return temp;
          //doesnt Work
           public Object removeLast()
              public Object removeLast()
             if (size()==0)
                return "empty list";
             Object temp= null;
             temp = last.getNext().getValue();
             last = last.getNext();
             size--;
             return temp;  
          }

    Well what is wrong with the code?
    Does it compile?
    Does it throw an error at runtime?
    Does it give you an unexpected answer?
    For solving problems like this with next/prev "pointers" I find diagramming boxes with arrows to help understand is an absolute requirement. Try figuring it out on paper.
    If you are removing the last item in the list, that means that the item directly before this one, has to the next one in the list
    Assuming you have a structure like this:
    ...-->  (n-1)  -->  (n)  --> (1) --> (2) -->...(n-1)Then removing item (n) you have to make (n-1) point at item (1) as item (n-1) becomes the new "last"
    So you have to have the item before the "last" element to keep the next/prev pointers correct.

  • Circular Linked List Help

    Hi,
    I'm developing a circular linked list class.. However everytime I add to the front of the list it overwrites the first element in the list.. I pretty confused at the moment. If anyone could assist me in what I'm doing wrong it would be greatly appreciated..
    My Class:
    public class CNode<T>
         public T nodeValue;          //data held by the node
         public CNode<T> next;     //next node in the list
         //default constructor; next references node itself
         public CNode()
              nodeValue = null;
              next = this;
         //constructor; initializes nodeValue to item
         //and sets the next to reference the node itself
         public CNode(T item)
              nodeValue = item;
              next = this;
    }My addFirst:
    public static <T> void addFirst(CNode<T> header, T item)
              CNode<T> curr;
              CNode<T> newNode = new CNode<T>(item);
              //header.next = newNode;
              //newNode.next = header;
              curr = header;
              newNode.next = header;
              curr.next = newNode;
         }

    You need a Node class and a class that manages the nodes. The class the manages the nodes is typically called something like MyLinkedList. The MyLinkedList class will typically have a member called 'head' or 'first' and another member called 'last', 'end', or 'tail'. Those members will contain references to the first node and the last node respectively.
    The methods like add(), remove(), find(), etc. will be members of the MyLinkedList class--not the Node class. The add() method of the MyLinkedList class will create a node, set the value of the node, and then set the next member to refer to the proper node or null if the node is added to the end of the list. Therefore, there is really no need for a default constructor in the node class. The MyLinkedList class will always set the value of the node, and then set it's next member to refer to something.
    You might want to try to write a linear linked list first, and get that working, and then modify it to make it a circular linked list. In addition, you should be drawing pictures of nodes with arrows connecting the different nodes to understand what's going on. Whenver the next member of a node refers to another node, draw an arrow starting at the next member and ending at the node it refers to. The pictures will be especially helpful when you write functions like add().
    Message was edited by:
    7stud

  • Circular linked list while loop

    i have a circular linked list and i'd like a while loop to iterate though all of them. my problem is that it always excludes the last node. i know why, it's due to the fact that "current.next != alive" skips it from ever accessing the last node. i can't seem to solve it. note that the last node in the list points to the first node (alive):
                   while(current.next != alive )
                        prev = prev == null ? prev = alive : prev;
                        //identify the name with it's matching node
                        if(name.equals(current.name.toLowerCase()))
                             prev.next = current.next;
                             dead = current;
                             current = current.next;
                             dead.next = null;
                             while(dead.next != null)
                                  dead = dead.next;
                        else
                             prev = current;
                             current = current.next;     
                   }

    //this class assists the client in managing a game of assassinations. it does so by providing options such as verifying a target's existence, getting the list of dead people, getting the lsit of alive people, and moving people from the alive to dead list
    public class AssassinManager
         private AssassinNode alive;
         private AssassinNode alive_tail;
         private AssassinNode dead;
         //pre: must send a string array
         //post: nodes are created
         public AssassinManager(String[] names)
              dead = null;
              alive = new AssassinNode(names[0]);
              AssassinNode current = alive;
              System.out.println(names[0] + " is first, " + names[(names.length-1)] + " is last\n\n");
              for(int i = 1; i < names.length; i++)
                   while(current.next != null)
                        current = current.next;
                   current.next = new AssassinNode(names);
              alive_tail = current.next = new AssassinNode(names[(names.length - 1)], alive);
         //post: outputs all the people still alive
         public void printKillRing()
              AssassinNode last = null, current = alive;
              while(current.next!= alive)
                   System.out.println(current.name + " is stalking " + current.next.name);
                   last = current.next;
                   current = current.next;
              System.out.println(current.name + " is stalking " + alive.name);
         //post: outputs a list of the dead people
         public void printGraveyard()
              AssassinNode last = null, current = dead;
              while(dead != null)
                   System.out.println(current.name + " was killed by " + current.killer);
                   last = current.next;
                   current = current.next;
         //pre: must send a string name
         //post: will return true/false depending on the input if the name is in the killing ring (alive)
         public boolean killRingContains(String name)
              AssassinNode current = alive;
              name = name.toLowerCase();
              while(current.next!= alive)
                   if(name.equals(current.name.toLowerCase()))
                        return true;
                   current = current.next;
              return false;
         //pre; must send a string name
         //post: will return true/false if the name is in the graveyard list
         public boolean graveyardContains(String name)
              AssassinNode current = dead;
              name = name.toLowerCase();
              while(dead != null && current.next != null)
                   if(name.equals(current.name.toLowerCase()))
                        return true;
                   current = current.next;
              return false;
         //post: checks if game is over by seeing if there is more than 1 player
         public boolean gameOver()
              AssassinNode current = alive;
              if(current.next == null)
                   return true;
              return false;
         //post: outputs the winner's name
         public String winner()
              AssassinNode current = alive;
              if(current.next == null)
                   return alive.name;
              return null;
         //pre: must send a string name that exists is alive
         //post: will remove the user from the alive list and add it to the killed list
         public void kill(String name)
              //check if person exists to remove them from alive list
              if(killRingContains(name.trim()) == true)
                   AssassinNode prev = null, current = alive, dead = this.dead;
                   name = name.toLowerCase();
                   while(current != null)
                        System.out.println(current.name);
                        if(name.equals(current.name.toLowerCase()))
                             prev = prev == null ? alive_tail : prev;
                             prev.next = current.next;
                             //dead = dead == null ? current : dead;
                             //while(dead.next != null)
                                  //dead = dead.next;
                             if(prev.next == alive)
                                  break;
                             current = prev.next;
                        else
                             if(current.next == alive)
                                  break;
                             prev = current;
                             current = current.next;
    }Edited by: ixxalnxxi on Apr 27, 2008 12:58 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Why LinkedList uses doubly linked list and not single link list

    Hi,
    Please help me to understand the concept behind java using doubly linked list for LinkedList and not single link list?
    Edited by: user4933866 on Jun 26, 2012 11:22 AM
    Edited by: user4933866 on Jun 26, 2012 11:25 AM
    Edited by: EJP on 27/06/2012 08:50: corrected title to agree with question

    EJP wrote:
    Could you help me with one real world use case where we need to traverse linklist and arraylist in backward direction other than printing the linklist or arraylist in reverse order. One example is that you might want to use it as a stack. For a very large (+very+ large) stack it would out-perform the Vector-based Stack in the API.The first thing that pops into my head is an undo/redo function for a text editor. Each edit action is dumped onto such a stack. Each time you hit CTRL+Z to undo an action you go back in the stack. Each time you hit CTRL+Y to redo the action you go forward again.

  • How to create links and how to use that links to go to other pages?

    my question is....how to create links...i mean by using make link option.....when we do right click on a word,etc in the design view.....and my other question is.....how to use that links to go to other pages.....i mean when i click on a link...it takes me to another web page.....

    Please do not post the same subject to more than one forum.

  • How to make a linked list?

    I've seen how to implement a linked list in oracle ? but it's not what I'm interested in.
    First of all, it is just a curiosity, no serious task behind it. I think I've almost made a linked list (of chars) type, however it misses the notion of empty list and thus I virtually cannot construct it.
    create or replace type LString as object
      head Char,
      tail ref LString,
      member function cons(
        p_x Char)
        return LString
    create or replace type body LString is
      member function cons(
        p_x Char)
        return LString
      is
        xs LString;
      begin
        xs := LString(head => p_x, tail => self.tail);
        return xs;
      end;
    end;I need to be able to make empty list to construct other lists, for example:
    empty_lstring.cons('H').cons('i').cons('!')
    How can I do it?
    Edited by: 922141 on 12.07.2012 7:02

    I need to be able to make empty list to construct other lists, for example:
    empty_lstring.cons('H').cons('i').cons('!')
    Why ? Can you mention one procedural language who can do this? I can't! Can you?
    Sybrand Bakker
    Senior Oracle DBA

  • I need help with circular linked list

    Hi,
    I need help with my code. when I run it I only get the 3 showing and this is what Im supposed to ouput
    -> 9 -> 3 -> 7
    empty false
    9
    empty false
    3
    -> 7
    empty false
    Can someone take a look at it and tell me what I'm doing wrong. I could nto figure it out.
    Thanks.This is my code
    / A circular linked list class with a dummy tail
    public class CLL{
         CLLNode tail;
         public CLL( ){
              tail = new CLLNode(0,null); // node to be dummy tail
              tail.next = tail;
         public String toString( ){
         // fill this in. It should print in a format like
         // -> 3 -> 5 -> 7
    if(tail==null)return "( )";
    CLLNode temp = tail.next;
    String retval = "-> ";
         for(int i = 0; i < -999; i++)
    do{
    retval = (retval + temp.toString() + " ");
    temp = temp.next;
    }while(temp!=tail.next);
    retval+= "";}
    return retval;
         public boolean isEmpty( ){
         // fill in here
         if(tail.next == null)
              return true;
         else{
         return false;
         // insert Token tok at end of list. Old dummy becomes last real node
         // and new dummy created
         public void addAtTail(int num){
         // fill in here
         if (tail == null)
                   tail.data = num;
              else
                   CLLNode n = new CLLNode(num, null);
                   n.next = tail.next;
                   tail.next = n;
                   tail = n;
         public void addAtHead(int num){
         // fill in here
         if(tail == null)
              CLLNode l = new CLLNode(num, null);
              l.next = tail;
              tail =l;
         if(tail!=null)
              CLLNode l = new CLLNode(num, null);
              tail.next = l;
              l.next = tail;
              tail = l;
         public int removeHead( ){
         // fill in here
         int num;
         if(tail.next!= null)
              tail = tail.next.next;
              //removeHead(tail.next);
              tail.next.next = tail.next;
         return tail.next.data;
         public static void main(String args[ ]){
              CLL cll = new CLL ( );
              cll.addAtTail(9);
              cll.addAtTail(3);
              cll.addAtTail(7);
              System.out.println(cll);          
              System.out.println("empty " + cll.isEmpty( ));
              System.out.println(cll.removeHead( ));          
              System.out.println("empty " + cll.isEmpty( ));
              System.out.println(cll.removeHead( ));          
              System.out.println(cll);          
              System.out.println("empty " + cll.isEmpty( ));
    class CLLNode{
         int data;
         CLLNode next;
         public CLLNode(int dta, CLLNode nxt){
              data = dta;
              next = nxt;
    }

    I'm not going thru all the code to just "fix it for you". But I do see one glaringly obvious mistake:
    for(int i = 0; i < -999; i++)That says:
    1) Initialize i to 0
    2) while i is less than -999, do something
    Since it is initially 0, it will never enter that loop body.

  • How to use a Sybase table in Oracle SQL statement?

    How to use a Sybase table in Oracle SQL statement?
    Sybase version : 11.9.2.4
    Oracle version : 10.2.05
    Thanks.

    user12088323 wrote:
    How to use a Sybase table in Oracle SQL statement?
    Sybase version : 11.9.2.4
    Oracle version : 10.2.05
    Thanks.Any Oracle client connected to the Oracle database can access Sybase data through the <font style="background-color: #FFFFCC">Database Gateway for Sybase</font> (it requires an additional license) or the <font style="background-color: #FFFFCC">Database gateway for ODBC</font> (it's free).
    The Oracle client and the Oracle database can reside on different machines. The gateway accepts connections only from the Oracle database.
    A connection to the gateway is established through a database link when it is first used in an Oracle session. In this context, a connection refers to the connection between the Oracle database and the gateway. The connection remains established until the Oracle session ends. Another session or user can access the same database link and get a distinct connection to the gateway and Sybase database.
    Database links are active for the duration of a gateway session. If you want to close a database link during a session, you can do so with the ALTER SESSION statement.
    To access the Sybase server, you must create a <font style="background-color: #FFFFCC">database link</font>. A public database link is the most common of database links.
    SQL> CREATE PUBLIC DATABASE LINK dblink CONNECT TO
    2  "user" IDENTIFIED BY "password" USING 'tns_name_entry';
    --dblink is the complete database link name.
    --tns_name_entry specifies the Oracle Net connect descriptor specified in the tnsnames.ora file that identifies the gatewayAfter the database link is created you can verify the connection to the Sybase database, as follows:
    SQL> SELECT * FROM DUAL@dblink;
    Configuring Oracle Database Gateway for Sybase
    <font style="background-color: #FFFFCC">{message:id=10649126}</font>

  • How to create database link from oracle to sql server

    Please help with how to create database link from oracle to sql server
    Best regards,
    Vishal

    Please help with how to create database link from oracle to sql server
    Best regards,
    Vishal
    Hi Vishal,
    I found a lof of information regarding how to create a database link from Oracle to SQL Server, please see:
    https://www.google.co.in/?gws_rd=cr&ei=vd3XUvGFO8TgkAXqlYCADg#q=how+to+create+database+link+from+oracle+to+sql+server
    We discuss SQL Server related issue in this forum. If you have any more question regarding Oracle, please post it in Oracle communities forum for better support.
    Regards,
    Elvis Long
    TechNet Community Support

  • How to concatenate two linked lists?

    Can anyone help me with this? I'm stuck. I'm trying to concatenate two linked lists. I've created a method that adds a node to the beginning of a list and a second method to concatenate. My first method works, but not my second...
    First method:
    public static Node insertFirst(Node head, Node node){
              Node newNode = new Node();          // declare and initialize newNode.
              newNode = node;                    // store the new item in the new node.
              newNode.link = head;               // newNode.link points to the head.
              head = newNode;                    // update head to be newNode.
              return head;
         }Here is where I have my problem:
    public static Node mergeTwoLists(Node a, Node b){
              Node heada = a;
              Node headb = b;
              if(heada == null)
                   return headb;                    //if heada is null then returns list headb.
              else if(headb == null)
                   return heada;                    //if headb is null then returns list heada.
              else if(heada == null && headb == null)     //if both lists are null, returns null.
                   return null;
              else if(heada.link == null){     //only one element in heada.
                   headb = insertFirst(b, a);               // inserts the element in heada into headb.
                   return headb;
              }//end else if(heada.link == null).
              else if(headb.link == null){     //only one element in headb.
                   heada = insertFirst(a,b);               // inserts the element in headb into heada.
                   else {
                        mergeTwoLists(heada.link, headb);
                        return heada;
                   }//end else
              return heada;
              }//end mergeTwoLists method.I think in this method I'm only adding the nodes if there is only one node in one of the lists. But if there are more than one element in a list...I'm confused as to how to code the last else statement that contains the recursive call.
    Can someone help?
    Thanks
    aiki985

    Can't you just point the tail of A to the head of B?
    I don't think I'd do this recursivly at all. Use a
    while look to find the last node in A and then link
    it to whatever the first element in B is.
    while(A.next != null){
    A = A.next;
    A.next = B;
    Java that up a bit and check for nulls and it should
    work.o.k. thanks...let me try that. It does seem awkward recursively...
    aiki985

  • How to use quick link property in the km navigation iview

    Hi all
    I have requirement.
    T structured lables
    one on top and rest 12 at the bottem in 3 columns, 4 rows.
    when i click the lable it should connect to a  respective folder in the KM
    this entire page have to be connected to a folder link...ie when i click this folder link this page with T structured lables have to come and when i click each lable respective folders should open...
    so for that i have created  one KM Document iview(this is like heading in the page) and 12 KM Navigation iviews(pointing to  respective folders)
    after that which layout will be suitable for this in page layout???
    if i add all iviews into a  one single page
    how to connect lables to folder???
    one of my friend have suggested to use '"quicklink'" property along with html page...???
    how to use it ???
    so pls do help me???
    my dead line is by today evening i.e 2.12.08
    pl do reply me as soon as posible
    thanks and regards
    Gayathri vuthukota

    hi Nikhil
    cau u explain me in detail please.
    I have done with HTML page and attached to Km document iview.and i have my 12 Km navigation i views.
    Then create static Links on HTML page to navigate to other iviews. It can be created by using the Insert link in Km tool of the html editor available in Km. For opening a url iview from a link you can write this for executing the 'donavigate method' to open the iview you needed.???
    what is EPCF client eventing???
    thanksn regards
    Gayathri

Maybe you are looking for