Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Make a Python program that: Uses argparse to read command-line arguments. Uses t

ID: 3755538 • Letter: M

Question

Make a Python program that:

Uses argparse to read command-line arguments.

Uses the library.expect module to SSH to a switch specified on the command-line.

On that switch, run the command ‘show spanning-tree vlan X’ where is the VLAN ID (integer) supplied on the command-line

Print the output, but only show the output for “Bridge ID” and “Root ID” or “spanning-tree instance does not exist.”

Uses the library.snmp module to get the uptime of the same switch.

This requires using the library.keys module to get the “current SNMP read-only community string”

Print the uptime raw value and the human-readable value.

Explanation / Answer

Answer:

When we need to compare AVL tree with simple binary search tree (BST) without balancing, then AVL will consume more memory (reason is - each node has to remember its balance factor) and each operation can be slower (because we need to maintain the balance factor and sometimes perform rotations too).

As mentioned, BST without balancing has a very bad (linear) worst case. But if we know that this worst case won't happen to us, or if we are fine if the operation is slow in rare cases, BST without balancing might be better than AVL.

/*
* SIMPLE BST data structure without balancing info.
*
*/

#define RIGHT (1)
#define LEFT (0)

#define TREE_NUM_CHILDREN (2)

struct tree {
/* Now we will make this an array so that some operations symmetric can be made */
struct tree *child[TREE_NUM_CHILDREN];
int key;
int height; /* This is the height of this node */
size_t size; /* This will be the size of subtree rooted at this node */
};

#define TREE_EMPTY_HEIGHT (-1)
#define TREE_EMPTY (0)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote