User Profile

Collapse

Profile Sidebar

Collapse
randysimes
randysimes
Last Activity: Nov 19 '10, 07:29 PM
Joined: Oct 5 '09
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • randysimes
    started a topic AVL (Height Balanced) Tree
    in C

    AVL (Height Balanced) Tree

    I have to code Insert/Remove for and AVL tree derived from a BST. I have a fully functional Insert working. Do determine the heights, I call a Height function that recursively calculates the height of each node. Does this violate the constraints on an AVL tree that all functions are to run in O(log n)?
    See more | Go to post

  • randysimes
    started a topic AVL Tree Insertion/Removal Repairs
    in C

    AVL Tree Insertion/Removal Repairs

    I have Insert, Remove, RotateLeft, and RotateRight all tested and functioning. However, the Insert/Remove are derived from a Binary Search Tree. I'm really lost as to how to determine when and where to call the Rotate functions after my calls to Insert and Remove to make the tree balanced between -1 and 1. I read the wiki article but it didn't do much for me. What advice can you give on the topic or what recommended site can I visit for a nice concrete...
    See more | Go to post

  • randysimes
    started a topic Bit masking
    in C

    Bit masking

    I have a 32bit number (unsigned int), I want to set another 32bit number to only a certain series of bits. For instance:
    1000 0000 1011 1010 0111 1001 1101 0011 is what is given.

    I want to set another number to bits 3 - 16 from the left, so bits 17 - 30.

    I tried newNum = (given & 0x3FFF0000) but it is incorrect.
    1000 0000 1011 1010 0111 1001 1101 0011given
    ...
    See more | Go to post

  • randysimes
    started a topic Accessing functions of another file
    in C

    Accessing functions of another file

    In a simple form, I fully understand how to do this.
    Code:
    //foo.h
    class Foo;
    
    Class Foo
    {
      void someFunction(int);
    }
    
    //foo.cpp
    #include <foo.h>
    
    int main()
    {
      Foo foo;
      foo.someFunction(bar);
      ...
      return 0;
    On the other hand, when I have:
    Code:
    //foo.h
    ...
    namespace myStuff
    {
      template typename
    ...
    See more | Go to post

  • randysimes
    started a topic Use Iterator to obtain vector index
    in C

    Use Iterator to obtain vector index

    I am creating a sorted vector using lower_bound. I set an Iterator to lower_bound to determine the place a 'val' needs to be. I then PushBack(val) to create the needed space for the item. I have tried several methods to then move the the 'val' from the back to it's lower_bound location, but either get a segfault or the items are not in "less than" order. I can easily do this using the 'index' of the items vs. trying to use Iterators. How...
    See more | Go to post

  • randysimes
    replied to Backtrack in maze
    in C
    Code sample will be posted around 8:00pm EST. I'm in class now
    See more | Go to post

    Leave a comment:


  • randysimes
    replied to Backtrack in maze
    in C
    I'm not. I'm not sure how to
    See more | Go to post

    Leave a comment:


  • randysimes
    replied to Backtrack in maze
    in C
    Yes, I have a stack that I push unvisited cells to, when it reaches a dead end, it breaks.
    See more | Go to post

    Leave a comment:


  • randysimes
    started a topic Backtrack in maze
    in C

    Backtrack in maze

    I have a maze setup by rows and columns.
    0 1 2 3 4 5
    6 7 8 9 10 11...

    Given a starting point and an ending point of say start = 0 and goal = 8

    Each cell has a list of its cells that it has access to, no walls between.

    I begin solving the maze by starting at start and going to its next possible cell, the lowest numbered one. So if cell 3 has access to 4 and 9, it goes to 4. I then 'mark'...
    See more | Go to post

  • randysimes
    replied to Converting A Basic Program to A C++ Program
    in C
    Code:
    int a(3), S, R;
    for (S=1; S <=5; S+=2)
    {
    R=2
    N=((2^R)*S)+1
    if (int(((a^S)-1)/((2^R)*S+1))==((a^S)-1)/N)
     std::cout<< "yes\n"
                  << "S= " << S
                  << "\nR= " << R
                   << "\na= " << a;
     else 
       std::cout << "no";
    }
    See more | Go to post

    Leave a comment:


  • randysimes
    replied to Passing pointer as parmaneter
    in C
    Banfa, thanks, but I was going in the wrong direction with that.
    However, say I have
    Code:
    class Foo
    {
      Bar * start;
      start = &fooVector[size_t]
    ...
    }
    class Bar
    {
    ...
    }
    How can I output the value of start? I did not overload the operator << so I cannot cout << *start
    See more | Go to post

    Leave a comment:


  • randysimes
    replied to Passing pointer as parmaneter
    in C
    So, say that the void Add(Foo * N) function has access to a private variable that is a list and I want to add more than one item at any given item in the list. For instance, I want to add a North, and South to item 0 in the list, how can I do this?
    See more | Go to post

    Leave a comment:


  • randysimes
    replied to Passing pointer as parmaneter
    in C
    Thanks so much, weaknessforcats !
    See more | Go to post

    Leave a comment:


  • randysimes
    started a topic Passing pointer as parmaneter
    in C

    Passing pointer as parmaneter

    I have to pass a pointer as a parameter, but I can't quite get the syntax down.

    I have this variable:
    std::vector<Foo > fooVector;

    And this function of another class, Foo
    void Add (Foo * N)

    So I need to pass fooVector_[size_t] to the Add function.

    I have tried this:
    Foo foo;
    foo.Add(foo.foo Vector_[size_t]) but get the error (shortened) Needs class::Foo*...
    See more | Go to post

  • randysimes
    started a topic const char* and char* concatenation
    in C

    const char* and char* concatenation

    I am trying to concatenate these two items and I get an error about binary conversion.
    This is how I have it set up:
    bool concatenate (const char* foo, char* bar)
    const char* foobar = foo + bar
    See more | Go to post

  • randysimes
    started a topic Reads input endlessly
    in C

    Reads input endlessly

    I have a program to read in words and sort those words into lexicographical order. The problem I have is that it reads the input file endlessly. I know it does not reach the output section because the output file is not created.

    Code:
    size_t maxArraySize = 1000;
    
    int main (int argc, char* argv[])
    {
    	char* a [maxArraySize];
        unsigned int count = 0;
        
    	if (argc < 3) //checks
    ...
    See more | Go to post

  • randysimes
    replied to Why?
    in C
    Is it the addess of the variable or is it passed by reference? I couldn't find much about & online.
    See more | Go to post

    Leave a comment:


  • randysimes
    replied to Why?
    in C
    I can see that you can change the value of the & variable, that it.
    See more | Go to post

    Leave a comment:


  • randysimes
    started a topic Pointer and integer expressions
    in C

    Pointer and integer expressions

    I have a review test question and was wondering why the answers are the way they are. Could someone please explain what you can and cannot do with the following?

    Which of the following expressions are allowed, given that i and j are pointers to the same type and n is an integer?
    n = i / j

    n = j - i correct?

    n = i % j

    n = i + j

    n += j

    j += n correct?...
    See more | Go to post

  • randysimes
    started a topic Why?
    in C

    Why?

    I was wondering why the output of the following code is:
    x = 1
    y = 2
    z = 3
    x = 2 (understand here up)
    y = 2 (Why isn't it 3)
    z = 5 (Why isn't it 4)
    Code:
    int F(int& x, int y)
    {
    x = x+1;
    y = y +1;
    return x + y;
    }
    
    int main()
    {
    int x, y, z;
    x = 1, y = 2, z = 3;
    std::cout << "x=" << x << '\n'
    ...
    See more | Go to post
No activity results to display
Show More
Working...