Khan Academy (2019) Measures of Central Tendency and Khan Academy (2019) Measures of Dispersion what is the difference between and common?
In: Computer Science
Can you add code to this so that it finishes the combine function. Given two words as input, the output of the program should be the two words combined together with a space between them. Not allowed to use any external libraries for this assignment.
#include <stdio.h>
#include <stdlib.h>
void combine(char* p, char* q){
/* Add the necesary logic here to combine the strings
in the dynamic array p and q by inserting a space
between two words
and write the result back to p */
}
int main(){
/* No changes should be done in this part */
char* word1 = malloc(sizeof(char) * 128);
char* word2 = malloc(sizeof(char) * 128);
printf("Enter your first word:\t");
scanf("%s", word1);
printf("Enter your second word:\t");
scanf("%s", word2);
combine(word1, word2);
printf("%s\n", word1);
}
In: Computer Science
Verify Login Page that either gives error when not meeting the requirement or directing it to "blogs.php" when it's a successful log in..
Hi, so this is actually my html code for the log in and sign up page and I just needed help creating a verify log in/ sign up page with exception handling. Username has to be at least 6 character long. Password has to be 6 characters long and end with a number.
Blogs.com
"
"index.html"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8" />
<title>Blogs.com</title>
</head>
<body>
<h2>Sign in </h2>
<p> Enter your username and password to sign
in!</p>
<form method="POST" action ="blogs.php">
<p> User Name <input type ="text"
name="username"/></p>
<p> Password <input type="text" name ="passwordname"
/></p>
<input type="submit" value= "Sign in"/></p>
</form>
<p> Sign up if you're a first time user!</p>
<form method="POST" action ="UserRegistration.php">
<input type="submit" value= "Sign up!"/></p>
<br /><br />
<script>
var date =new Date();
document.write("Today " ,date);
</br>
</script>
</body>
</html>
"UserRegistration"
<?php
session_start();
$_SESSION = array();
session_destroy();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>User Registration</title>
<meta
http-equiv="content-type" content="text/html; charset=iso-8859-1"
/>
</head>
<body>
<h1>User
Registration</h1>
<h2>Register / Log In</h2>
<p>New
user's, please complete the top form to register as a new user.
Returning user's, please complete
the second form to log in.</p>
<hr
/>
<h3>User
Registration</h3>
<form
method="post" action="Register.php?<?php echo SID;
?>">
<p>Enter your Name:
First <input type="text"
name="first" />
Last <input type="text"
name="last" />
</p>
<p>Enter your e-mail address:
<input type="text"
name="email" />
</p>
<p>Enter your password:
<input type="password"
name="password" />
</p>
<p>Confirm your password:
<input type="password"
name="password2" />
</p>
<p>
<em>(Passwords are
case-sensitive and must be at least 6 characters
long)</em>
</p>
<input type="reset" name="reset" value="Reset
Registration Form" />
<input type="submit" name="register"
value="Register" />
</form>
<hr
/>
<?php
$nag_counter = 0;
if(isset($_COOKIE['userVisit']))
$UserVisit = "<p>Your
visit number is $nag_counter was on " .
$_COOKIE['userVisit'];
else
$UserVisit = "<p>This
is your first visit!</p>\n";
++$nag_counter;
setcookie("userVisit", date("F j, Y, g:i a"),
time()+60*60*24*365);
?>
<?php
echo $UserVisit;
?>
</body>
</html>
"
In: Computer Science
1. Add the function int getNodeLevel (T value) to the Binary Search Tree class provided below. The function should return the level of the node value in the Binary Search Tree.
Hint:
Set currentNode to root
Initialize level = 0
while currentNode != Null
if currentNode element = value return level
else move to either the right child or the left child of the currentNode, update the loop, and repeat the loop
Function should return -1 if value is not in the tree
#include <iostream>
#include <vector>
using namespace std;
//****** The Node class for the Binary Search Tree ******
template<typename T>
class Node
{
public:
Node();
Node(T e, Node<T>* r, Node<T>* l);
T element; // holds the node element
Node<T>* right;
Node<T>* left;
};
//============ implementation of the constructors of the Node
template<typename T>
Node<T>::Node() { right = left = NULL; }
template<typename T>
Node<T>::Node(T e, Node<T>* r, Node<T>* l) { element = e; right = r; left = l; }
//=============== Binart Searct Tree (BST) class ===========
template<typename T>
class BTree
{
public:
BTree() { root = NULL; }
BTree(Node<T>* rt) { root = rt; }
void BSTInsert(T value);
void BSTRemove(T value);
Node<T>* & getRoot() { return root; } // returns the pointer to the root
Node<T>* BSTsearch(T value);
private:
Node<T>* root; // a pointer to the root of the tree
};
template<typename T>
Node<T>* BTree<T>::BSTsearch(T value)
{
// set cur to the tree root, traverse down the tree to find the element.
// Do not use the root, if you move the root the tree will be lost.
Node<T>* cur = root;
while (cur != NULL)
{
if (value == cur->element)
return cur;
else if (value < cur->element)
cur = cur->left;
else
cur = cur->right;
}
return NULL;
}
// traverse down the tree and inserts at the bottom of the tree as a new leaf
template<typename T>
void BTree<T>::BSTInsert(T value)
{
Node<T>* newNode = new Node<T>(value, NULL, NULL); // dynamically create a node with the given value
if (root == NULL) //Empty tree, fisrt node.
root = newNode;
else
{
Node<T>* r = root;
while (r != NULL)
{
if (value < r->element)
{
if (r->left == NULL)
{
r->left = newNode; //insert the node
r = NULL; // end the loop.
}
else
r = r->left; // keep going to the left child
}
else
{
if (r->right == NULL)
{
r->right = newNode;
r = NULL;
}
else
r = r->right;
}
}
}
}
//Three cases to consider when removing an element from a BST
template<typename T>
void BTree<T>::BSTRemove(T value)
{
Node<T>* parent = NULL; // Need to track the parent of the node to be deleted
Node<T>* current = root; // current will point to the node to be deleted
//find the node to be removed
while (current != NULL && current->element != value)
{
if (value < current->element)
{
parent = current; current = current->left;
}
else
{
parent = current; current = current->right;
}
}
if (current != NULL) // The node to be deleted is found
{
//Case A : the node is a leaf node
if (current->left == NULL && current->right == NULL)
{
if (parent->right == current)
parent->right = NULL;
else
parent->left = NULL;
delete current;
}
//Case B: the node has two children
// Must find the smalles element in the right subtree of the node, which is
//found by going to the right child of the node then all the way to the left.
else if (current->left != NULL && current->right != NULL)
{
Node<T>* succ = current->right; // go to the right child of the node to be removed
parent = current; // initialize parent node
if (succ->left == NULL) // right child of the node has no left child
{
parent->right = succ->right;
current->element = succ->element;
delete succ;
}
else //otherwise keep going left
{
while (succ->left != NULL) // then find the smallest element in the left subtree
{
parent = succ;
succ = succ->left;
}
current->element = succ->element; //Replace the node to be deleted by the succ node
parent->left = NULL; // skip the succ node
delete succ;
}
}
else // Case C: Node has one child
{
if (root->element == value) //if the node is the root node treat differently
{
cout << "here\n";
if (root->right != NULL)
root = root->right;
else
root = root->left;
}
else // a non root node with one child to be removed
{
if (current->left != NULL)
parent->left = current->left;
else
parent->right = current->right;
}
delete current;
}
}
}
int main()
{
BTree<int> bst;
bst.BSTInsert(29);
bst.BSTInsert(50);
bst.BSTInsert(78);
bst.BSTInsert(39);
bst.BSTInsert(21);
return 0;
}In: Computer Science
Method: DoublyLinkedList reverse(DoublyLinkedList list) Reverse() method accepts a DoublyLinkedList of Character as the argument, reverses the elements in the list, and returns the resulting list. For example:
The given list is
'a' 'b' 'c' 'd' 'e'
The return list should be
'e' 'd' 'c' 'b' 'a'
In: Computer Science
In: Computer Science
Consider the Minimum Spanning Tree Problem on an undirected graph G=(V,E), with a cost ce ≥0 on each edge, where the costs may not all be different. If the costs are not all distinct, there can in general be many distinct minimum-cost solutions. Suppose we are given a spanning tree T ⊆ E with the guarantee that for every e ∈ T, e belongs to some minimum-cost spanning tree in G. Can we conclude that T itself must be a minimum-cost spanning tree in G? Give a proof or a counterexample with explanation.
In: Computer Science
In: Computer Science
In: Computer Science
each one of the following languages defined over {0,1}, give the transition diagram of a deterministic, single tape Turing Machine.
{03i 1 02i 1 0i | i > 0}
In: Computer Science
Provided that c1, c2 and c3 are of appropriate ranges. Use transform() algorithm so that it copies the larger of the corresponding elements from c1 and c2 to c3. That is, if
c1 = {1, 2, 3, 4, 5} and c2 = {5, 4, 3, 2, 1}
then c3 should become c3={5, 4, 3, 4, 5}
In: Computer Science
name two differences in Chappe's and mMorse's inventions
In: Computer Science
C++ Lexicographical Sorting
Given a file of unsorted words with mixed case: read the entries in the file and sort those words lexicographically. The program should then prompt the user for an index, and display the word at that index. Since you must store the entire list in an array, you will need to know the length. The "List of 1000 Mixed Case Words" contains 1000 words.
You are guaranteed that the words in the array are unique, so you don't have to worry about the order of, say, "bat" and "Bat."
For example, if the array contains ten words and the contents are
cat Rat bat Mat SAT Vat Hat pat TAT eat
after sorting, the word at index 6 is Rat
You are encouraged to use this data to test your program.
In: Computer Science
This is a c++ code. Write a series of assignment statements (complete executable code) that find the first three positions of the string “and” in a string variable sentence. The positions should be stored in int variables called first, second and third. You may declare additional variables if necessary. The contents of sentence should remain unchanged. The sentence can be completely random.
Im having a large problem with this. It's a simple c++ code, but im unable to get it. Thank you.
In: Computer Science
Please write JavaScript and HTML code for the following problems
Problem 1 - Array Usage
Ask the user to enter positive numeric values. Store each value in an array. Stop reading values when the user enters -1. After all values have been entered, calculate the sum and the average of the values in the array (if you do not know what a sum or average is, or how to calculate them, it is your responsibility to look up this information). Print out the values entered by the user, the sum of those values, and the average value.
You must create one function that calculates the sum of the values in the array and one function that calculates the average of the values in the array.
Problem 2 - Circles
For this problem, you will create a simple HTML page that allows the user to draw circles by clicking inside of a canvas element.
The HTML page shall contain a title, a header, two text fields, and a canvas. The title shall include your name. The header shall contain the text "Problem 2". The first text field shall have a label indicating that the field controls the number of circles that will be drawn. The second text field shall have a label indicating that the field controls the radius of the circles that will be drawn. The canvas shall have a height of 400 pixels and a width of 600 pixels.
The HTML page shall also contain a script that uses an event listener to draw circles whenever the user clicks inside of the canvas element with their mouse. The number of circles to draw, and the radius of the circles, shall be obtained from the text fields. Each circle shall be colored with an alpha value of 0.1. The canvas shall be cleared before any circle is drawn. The x and y position of each circle shall be randomly determined. You can use the following code to assign a random value to x and y:
let x = Math.floor(Math.random() * (width - 2 * r)) + r; let y = Math.floor(Math.random() * (height - 2 * r)) + r;
In: Computer Science