Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 160
» Latest member: zezima
» Forum threads: 439
» Forum posts: 1,391

Full Statistics

Online Users
There are currently 6 online users.
» 1 Member(s) | 5 Guest(s)
dzung

Latest Threads
Will the vertex not be a ...
Forum: Project 3
Last Post: ACCD
7 hours ago
» Replies: 0
» Views: 12
Accessing Test Cases
Forum: Project 2
Last Post: rshowe
Yesterday, 08:03 AM
» Replies: 0
» Views: 13
Minimum Depth Test #2
Forum: Project 2
Last Post: rshowe
Yesterday, 08:01 AM
» Replies: 0
» Views: 15
Method to get last submis...
Forum: Project 2
Last Post: rcfrederick
11-23-2017, 07:52 PM
» Replies: 1
» Views: 26
A lot of new test cases
Forum: Project 3
Last Post: rcfrederick
11-23-2017, 07:50 PM
» Replies: 0
» Views: 26
Test files
Forum: Project 2
Last Post: ianbway
11-23-2017, 04:48 AM
» Replies: 5
» Views: 252
Finishing extremely effic...
Forum: Project 2
Last Post: stvnengineer
11-20-2017, 03:30 PM
» Replies: 4
» Views: 139
Exam Date/Time
Forum: Final Exam
Last Post: ianbway
11-19-2017, 08:00 PM
» Replies: 1
» Views: 57
Some large input test cas...
Forum: Project 3
Last Post: ZachWassynger
11-18-2017, 09:59 PM
» Replies: 3
» Views: 121
Inconsistencies between t...
Forum: Project 3
Last Post: radagast
11-18-2017, 09:22 PM
» Replies: 1
» Views: 66

 
  How to deal with NULL pointers?
Posted by: alexbusol - 11-13-2017, 04:33 PM - Forum: Project 2 - Replies (1)

I've ran into some issues when there is a NULL pointer to a node left during the deleteRBT process. This happens when frequency of an element goes to 0 after delete. It causes my program to segfault when I pass it to any of the set/getBST methods. Pls see the screenshot attached. As you can see, n that is being passed has address 0x0, which I assume is a NULL pointer

How should I deal with that?



Attached Files Thumbnail(s)
   
Print this item

  statisticsRBT and statisticsGT
Posted by: ianbway - 11-13-2017, 04:15 AM - Forum: Project 2 - Replies (2)

I understand these methods should be pretty short. One line calls the words method for the respective tree and prints it. But isn't the next line really supposed to call the statisticsBST method on the underlying bst? Because in the spec it says:


  • statisticsRBT - This method should display the number of words/phrases (including duplicates) and then call the BST display method.
But the name of the method is statistics. And we already have displayRBT and displayGT to call the underlying displayBST method. And his tests seem to be using the statistics method.


Any clarification would be wonderful.

Print this item

Question Due Date
Posted by: awlay - 11-13-2017, 01:34 AM - Forum: Project 2 - Replies (5)

I forgot when Dr. Lusth said assign2-r1 was due. Is it Monday @5 or Tuesday @5?

Print this item

  What RBTVALUE should hold
Posted by: jaw653 - 11-11-2017, 11:49 PM - Forum: Project 2 - Replies (2)

So I've been going back and forth for a while now. Should RBTVALUE hold a void *value or a char *value? My understanding of say insertRBT is that the void *value parameter is actually an RBTVALUE that contains the value of the node (in our case, a string). So the comparator function would look "into" the RBTVALUE object to compare char * values? Do I have the correct understanding or am I completely off-based?

Print this item

  assign2-rerun-again differing public interface
Posted by: radagast - 11-11-2017, 02:35 AM - Forum: Project 2 - Replies (2)

It seems (atleast to me) that the assign2-rerun-again was invalid for cases where Lusth used his own BST code or where he used his own. Examples of this include test #2, #3, and #4.

Evidence of this to me includes the fact that the deletion of the root in test 2 was not found (it looks like he passed a BSTNODE * to deleteBST instead of a void *value (and thanks to no type checking on void * there is no compile error). Also his example prints out "swapped" (which is nowhere in the spec and nowhere in some of the later examples that I managed to pass). Output from test 3 exhibits the same behavior.

And the thing that tips it off to me the most is this compile error I received in test 4.

Code:
!! TRYING YOUR GT MODULE WITH ALTERNATE CODE

!! compiling the test program with your code
gcc -Wall -Wextra -g -c cda.c
gcc -Wall -Wextra -g -c queue.c
gcc -Wall -Wextra -g -c bst.c
gcc -Wall -Wextra -g -c gt.c
gt.c: In function ‘deleteGT’:
gt.c:127:29: warning: passing argument 2 of ‘deleteBST’ from incompatible pointer type [-Wincompatible-pointer-types]
        deleteBST(gt->tree, gtval);
                            ^
In file included from gt.c:8:0:
bst.h:27:21: note: expected ‘BSTNODE * {aka struct bstnode *}’ but argument is of type ‘GTVALUE * {aka struct gtvalue *}’
    extern BSTNODE *deleteBST(BST *,BSTNODE *);
                    ^
gcc -Wall -Wextra -g -c test-gt.c
gcc -Wall -Wextra -g -c string.c
gcc -Wall -Wextra -g -c integer.c
gcc -Wall -Wextra -g -o test-gt cda.o queue.o bst.o gt.o test-gt.o string.o integer.o
#./test-gt
!! compiling the test program with standard code
gcc -Wall -Wextra -g -c cda.c
gcc -Wall -Wextra -g -c queue.c
gcc -Wall -Wextra -g -c bst.c
gcc -Wall -Wextra -g -c gt.c
gcc -Wall -Wextra -g -c test-gt.c
gcc -Wall -Wextra -g -c string.c
gcc -Wall -Wextra -g -c integer.c
gcc -Wall -Wextra -g -o test-gt cda.o queue.o bst.o gt.o test-gt.o string.o integer.o
#./test-gt

Is anyone else having this issue or am I just going crazy? Seems to me that the compiler warning is a clear sign that his expectation for deleteBST in these tests is to have a BSTNODE *, which obviously causes problems when we expect a void *value. Also, the assign2-rerun does not have this issue.

Now that I think about it as well its extremely unlucky that the cast of a BSTNODE * to a INTEGER * doesn't freak out earlier and segfault instead of interpreting it as a value when calling the compare function. I guess since a void * is a 8 byte value in can be interpreted as a 4 byte integer without any issue (and is why the delete function does not segfault when it calls the compareINTEGER function with the invalid cast of the BSTNODE * to void * and then to INTEGER *.

Print this item

  Test files
Posted by: rcfrederick - 11-10-2017, 07:32 PM - Forum: Project 2 - Replies (5)

I have posted over 100 tests on github if anyone wants to compare outputs. The second half of the test are from submission0 and those should be exactly right. (I copied and pasted them from the gmail and fixed the weird formatting issues.) The other half are from my code that now passes all the submission0 tests.

You can find the tests at https://github.com/rcfrederick/cs201Assignment2.git.

The readme should tell you the three simple steps you need to perform to run the test. Everything should take about 25 seconds to run. (There are quite a few tests with the really long files but none of mine seem to take more than about 2 seconds each.)

Please tell me if you see any possible mistakes in my outputs.

Print this item

  Final Google Doc
Posted by: smmitchell2 - 11-10-2017, 02:43 PM - Forum: Miscellany - No Replies

Here is the link for us to study for the final.

https://docs.google.com/document/d/1dJt6...sp=sharing

Print this item

  RBT module segfaulting on Dr. Lusth's BST code but not my own?
Posted by: njvanhaute - 11-10-2017, 01:48 AM - Forum: Project 2 - Replies (2)

My RBT and GT modules work flawlessly when used with my own BST module, but when Dr. Lusth tests them with his BST code they either get into an infinite loop or they segfault. I'm wondering if it's possible that I implemented my BSTNODE methods differently than Dr. Lusth and that's what's causing the issue? The only thing I can think of is that the BSTNODE left, right, and parent properties aren't getting set properly during rotations because I'm using/implementing the BSTNODE methods differently than Dr. Lusth intended.

Has anybody else experienced anything similar?

For reference, my implementation of the BSTNODE methods:

Code:
extern void    *getBSTNODE(BSTNODE *n); // returns the generic value stored in n
extern void    setBSTNODE(BSTNODE *n,void *value); // sets the generic value stored in n to the one passed in
extern BSTNODE *getBSTNODEleft(BSTNODE *n); // returns the left child of n
extern void    setBSTNODEleft(BSTNODE *n,BSTNODE *replacement); // sets the left child of n to the node passed in
extern BSTNODE *getBSTNODEright(BSTNODE *n); // returns the right child of n
extern void    setBSTNODEright(BSTNODE *n,BSTNODE *replacement); // sets the right child of n to the node passed in
extern BSTNODE *getBSTNODEparent(BSTNODE *n); // returns the parent of n
extern void    setBSTNODEparent(BSTNODE *n,BSTNODE *replacement); // sets the parent of n to the node passed in

Print this item

  task 4 code help
Posted by: tegester - 11-09-2017, 09:05 PM - Forum: Assignment 3 - Replies (1)

Add these to make the book code work (I'm still working on finding scheme to scam problems) 

Code:
(define false #f)    
(define true #t)  
(define memq member?)
(define (error @)
  (println)
  (apply println @)
  )
(define (make-connector)
  (let ((value false) (informant nil) (constraints '()))
    (define (set-my-value newval setter)
      (cond ((not (has-value? me))
             (set! value newval)
             (set! informant setter)
             (for-each-except setter
                              inform-about-value
                              constraints))
            ((not (= value newval))
             (error "Contradiction" (list value newval)))
            (else 'ignored)))
    (define (forget-my-value retractor)
      (if (eq? retractor informant)
          (begin (set! informant nil)
                 (for-each-except retractor
                                  inform-about-no-value
                                  constraints))
          'ignored))
    (define (connect new-constraint)
      (if (not (memq new-constraint constraints))
          (set! constraints 
                (cons new-constraint constraints)))
      (if (has-value? me)
          (inform-about-value new-constraint))
      'done)
    (define (me request)
      (cond ((eq? request 'has-value?)
             (if (valid? informant) true false))
            ((eq? request 'value) value)
            ((eq? request 'set-value!) set-my-value)
            ((eq? request 'forget) forget-my-value)
            ((eq? request 'connect) connect)
            (else (error "Unknown operation -- CONNECTOR"
                         request))))
    me))

also arcos(x) = arctan((sqrt(1-x^2))/x)

Print this item

  assign2-rerun
Posted by: dzung - 11-09-2017, 04:30 PM - Forum: Project 2 - Replies (2)

On assign2's rerun, test#26 for example, the most recent test-0-6.corpus has:

Code:
1. yvzg
2. 1234
3. hello 1234 world
4.  1234
The behavior in the project spec is that the tokens to be inserted into trees are "yvzg," "hello," and "world." The numbers should just be cleaned to "" and not inserted. However, in tests #26 and #27, line 3 above is cleaned to "hello world" and inserted.

Print this item