(Using Matlab) Write a function to "smooth" a black-and-white image by replacing each pixel by the average of itself and its neighbors. In MATLAB a black-and-white image is just a matrix of 1s and 0s - 1 represents white, and 0 represents black.
To keep the algorithm simple, ignore the edges of the image - that is, do not change the first and last rows and columns.
function name = smooth_image()
input argument = input matrix
output argument = output matrix
The algorithm can be described as follows:
In: Computer Science
```please convert this code to make only using for loop not while loop
#include
#include
#define MAX_SIZE 500
int main()
{
char str[MAX_SIZE];
char tosearch[MAX_SIZE];
char part1[100];
char part2[100];
int cursor = 0, i, cnt1 = 0, cnt2 = 0, cnt = 0;
int j = 0;
int a = 0;
int b = 0;
int total = 0;
printf("Enter any string: ");
gets(str);
printf("Enter word to search occurrences: ");
gets(tosearch);
for (i = 0; i < strlen(tosearch); i++)
{
if (tosearch[i] == '*')
{
for (j = 0; j < i; j++)
{
part1[j] = tosearch[j];
}
a = j;
}
}
for (j = 0; j < strlen(tosearch) - a; j++)
{
part2[j] = tosearch[a + j + 1];
}
for (j = 0; j < a; j++)
{
printf("%c", part1[j]);
}
printf("\n");
for (j = 0; j < strlen(tosearch) - a - 1; j++)
{
printf("%c", part2[j]);
}
printf("\n");
b = strlen(part2);
while (cursor < strlen(str)) { // while the cursor is smaller
than length of main string while loop goes on
while (cnt1 != a) { // if the cnt1 is smaller than the part1
length the while loop goes on
if (str[cursor] == part1[0]) { // if the str[cursor] is correspond
to the first word of part1 go to for loop
for (i = 0; i < a; i++) {
if (str[cursor + i] == part1[i])
{
cnt1++; // count the number of matching letter of part1 and main
string
}
else { // else the cnt1 goes to 0 again and cursor goes
forward
cnt1 = 0;
cursor++;
break;
}
}
}
if (cursor > strlen(str) || cnt1 == a)
{
break;
}
cursor++; // cursor goes to the next letter
}
cursor += a; printf("the value of cursor %d ", cursor);
while (cnt2 != b) { // if cnt2 is less than the length of part2 the while loop goes on
if (str[cursor] == part2[0]) { // if the str[cursor] correspond
with part2[0] for loop goes on
for (i = 0; i < b; i++) {
if (str[cursor + i] == part2[i])
{
cnt2++; // count the matching letter of str and part2
}
else {
cnt2 = 0; // else cnt2 goes to 0 and cursor move on break free from
the for loop
cursor++;
break;
}
}
}
if (cursor > strlen(str) || cnt2 == b) // if the cursor is
larger than the strlen or cnt2 == (the length of part2) break
free
break;
cursor++; // move on to the next letter of the main string
}
if (cursor + b > strlen(str))
break;
cnt++;
cnt1 = 0;
cnt2 = 0;
}
printf("tot %d\n", cnt);
}
In: Computer Science
Define a class Fraction3YourName as follows,
/**
* Program Name: Fraction3YourName.java
* Discussion: Fraction3Yourname class
* written By:
* Date: 2019/09/19
*/
public class Fraction3YourName {
private int sign;
private int num;
private int denom;
public Fraction3YourName() {
//sign = ;
//denom = ;
}
public Fraction3YourName(int n) {
//sign = ;
//num = n;
//denom = ;
}
public Fraction3YourName(int s, int n, int d) {
//sign = s;
//num = n;
//denom = d;
}
}
You are asked to
Complete the definitions for the given constructors; and
Provide additional method members to allow the performance of
four simple
arithmetic operations: (1) Addition, (2) Subtraction, (3)
Multiplication, and (4)
Division; and
Provide one method member print() to display the
Fraction3YourName object.
/** REQUIRED PROGRAM OUTPUT
****************************************
* MENU – HW #3 *
* (1) Creating 2 Fraction3 Objects *
* (2) Performing Arithmetic Operations *
* (3) Displaying Fraction3 Objects *
* (4) Quit *
****************************************
Enter your option (1 through 4): 5
You are funny!
****************************************
* MENU – HW #3 *
* (1) Creating 2 Fraction3 Objects *
* (2) Performing Arithmetic Operations *
* (3) Displaying Fraction3 Objects *
* (4) Quit *
****************************************
Enter your option (1 through 4): 2
Creating 2 Fraction3 Objects –
// Your details
****************************************
* MENU – HW #3 *
* (1) Creating 2 Fraction3 Objects *
* (2) Performing Arithmetic Operations *
* (3) Displaying Fraction3 Objects *
* (4) Quit *
****************************************
Enter your option (1 through 4): 3
Displaying Fraction3 Objects –
// Your details
****************************************
* MENU – HW #3 *
* (1) Creating 2 Fraction3 Objects *
* (2) Performing Arithmetic Operations *
* (3) Displaying Fraction3 Objects *
* (4) Quit *
****************************************
Enter your option (1 through 4): 4
Performing Arithmetic Operations –
// Your details
****************************************
* MENU – HW #3 *
* (1) Creating 2 Fraction3 Objects *
* (2) Performing Arithmetic Operations *
* (3) Displaying Fraction3 Objects *
* (4) Quit *
****************************************
Enter your option (1 through 4): 4
Having fun!
by java programming
In: Computer Science
In: Computer Science
Problem 1: [10 Marks] Given a generic array with ‘n’ items (not only integers). Give a solution for checking whether there are any duplicate elements in the array or not? You just need to return a boolean (true or false). State the complexity of your solution. Can you come up with another solution that has O(n logn) complexity? Explain.
Problem 2: [10 Marks] Now consider the same problem as problem 1, but this time you only have positive integer numbers ranging from 0 to (n-1) in the array. Can you find a duplicate in O(n) complexity? Implement the solution.
Plz answer 2nd only
In: Computer Science
From 1977 to 1982, Internet Engineering Notes (IENs) were used to document and generate discussion about various topics related to the Internet and Internet protocols. One of the challenges facing the early Internet was inconsistent data representation, including byte ordering. IEN 137 addresses this challenge. Note the date of the IEN, which suggests that it is meant to be at least somewhat whimsical, although still addressing an important topic in computer and network systems.
In: Computer Science
Problem 5: (10 pts) Modify the patient class with two overloaded methods to display a bill for astandard visit based on age. In the first method do not use any parameters to pass in data. If the patient is over 65, then a standard visit is $75. If the patient is under 65, then the standard doctors office visit is $125. Build a second method where you pass in a discount rate. If the patient is over 65, then apply the discount rate to a standard rate of $125. Create a main method that calls both of these methods and displays the results
In: Computer Science
Problem 6: (20 pts) Create two subclasses called outpatient and inpatient which inherit from the patient base class. The outpatient class has an additional data field called doctorOfficeID and the inpatient class has an additional data item called hospitalID. Write a main method that creates inpatient and outpatient objects. Sets data for these objects and display the data.
In: Computer Science
Given an array A[0 … n-1], where each element of the array represent a vote in the election. Assume that each vote is given as an integer representing the ID of the chosen candidate. Can you determine who wins the election? What is the complexity of your solution? Hint: it is similar to finding the element that is repeated the maximum number of times.
In: Computer Science
/*
Array List
Modified from CS2 Software Design & Data Structures by Cliff Shaffer. OpenDSA
*/
#ifndef ALIST_H_RVC
#define ALIST_H_RVC
#include "List.h"
template // Array-based list implementation
class AList : public List {
private:
ListItemType* listArray; //Dynamic Array
(pointer)
int listSize; //Current number of list items
int curr; //Position of current element
int MAX_SIZE;
public:
//Constructors
AList() {
MAX_SIZE = 1000; // arbitrary
listArray = new
ListItemType[MAX_SIZE];
clear();
} //end constructor
// Create a new list element with maximum size
"MAX_SIZE" as a parameter
AList(int m) {
MAX_SIZE = m;
listArray = new
ListItemType[MAX_SIZE];
clear();
} //end constructor
bool isEmpty() const {
return listSize == 0;
}
void clear() { // Reinitialize the list
listSize = curr = 0; // Simply
reinitialize values
}
// Insert "it" at current position
// return value indicates success
bool insert(const ListItemType& it) {
if (listSize >= MAX_SIZE) return
false;
for (int i = listSize; i >
curr; i--) //Shift elements up
listArray[i] =
listArray[i - 1]; //to make room
listArray[curr] = it;
listSize++; //Increment list
size
return true;
}
// Append "it" to list
bool append(const ListItemType& it) {
cout << "\n\n******* This is
to be completed for the lab\n\n";
return true;
}
// Remove and return the current element
ListItemType remove() {
if (curr == listSize) curr--;
ListItemType it =
listArray[curr]; // Copy the element
for (int i = curr; i < listSize
- 1; i++) // Shift them down
listArray[i] =
listArray[i + 1];
listSize--; // Decrement size
if (curr > listSize) {
curr =
listSize;
}
return it;
}
void moveToStart() { curr = 0; } // Set to
front
void moveToEnd() { curr = listSize; } // Set to
end
void prev() { if (curr != 0) curr--; } // Move
left
void next() { if (curr < listSize) curr++; } //
Move right
int length() const { return listSize; } // Return list
size
int currPos() const { return curr; } // Return current
position
// Set current list position
to "pos"
bool moveToPos(int pos) {
if ((pos < 0) || (pos >
listSize)) return false;
curr = pos;
return true;
}
// Return true if current position is at end of the
list5
bool isAtEnd() const { return curr == listSize; }
// Return the current element
ListItemType getValue() const {
return listArray[curr];
}
bool find(const ListItemType& it) {
ListItemType curr =
cout << "\n\n*******
This is to be completed for the assignment\n\n";
return true;
}
bool findNext(const ListItemType& it) {
cout << "\n\n*******
This is to be completed for the assignment\n\n";
return true;
}
int count(const ListItemType& it) {
cout << "\n\n*******
This is to be completed for the assignment\n\n";
return 0;
}
};
#endif
Write the code for the find, findNext and count method in AList.h. This is an Array based list implementation problem in ADT, where we discuss about stacks
In: Computer Science
Choose an existing web site that you think can be improved or you have experienced problems with and explore the site thoroughly.
In: Computer Science
Find the K'th smallest element in an unsorted array of integers.
Find the K'th largest element in an unsorted array of integers.
please make two separate methods in java
In: Computer Science
C#
What to submit:
One zip file named Ass3.zip
This zip must contain one VS 2017 solution named Ass3, which contains one C# Windows Forms App project also named Ass3 and the project contains a default form, Form1.cs and Program.cs.
No change should be made in Program.cs, but your Form1 must be designed and implemented to satisfy the following requirements.
**Do not submit only a single file of the solution or project. The whole solution folder of VS 2017 must be zipped and submitted for grading.
Requirements:
In: Computer Science
What determines the capacity of an optical fibre strand?
In: Computer Science
Based on the statement, what are the possibilities that can happen to Uber Technologies Inc. autonomous vehicles Justify your answer. “Self-driving Uber kills Arizona woman in first fatal crash involving pedestrian”.
In: Computer Science