我对以下树的术语感到困惑,我一直在研究树,我无法区分这些树:
a)完整的二叉树
b)严格的二叉树
c)完整的二叉树
请帮我区分这些树.在数据结构中何时何地使用这些树?
我在接受采访时被问到这个问题
我原本应该在自己的位置反转字符数组而不是反转整个字符数组.
如果
char *ch="krishna is the best";
Run Code Online (Sandbox Code Playgroud)
然后我应该以这样的方式反转,输出应该是这样的
anhsirk si eht tseb
Run Code Online (Sandbox Code Playgroud)
我无法在面试中编写代码.任何人都建议我如何写这样做.
可以在指针的帮助下完成吗?
如果面试官没有告诉我将其反转到自己的位置,那么如果使用另一个数组字符数组很容易处理,那么在反转它之后会有新的字符串吗?
什么是 Theta 符号的简单英文解释?使用尽可能少的正式定义和简单的数学。
theta 表示法与 Big O 表示法有何不同?谁能用通俗的英语解释一下?
在算法分析中有怎么用?我很迷惑?
class ThreadSafe implements Runnable {
int arr[]=new int[]{1,2,3,4,5};
int sum=0;
public void run() {
int result=sum();
System.out.println("for "+Thread.currentThread().getName()+"the value is"+result);
}
public int sum() {
for(int i=0;i<5;i++) {
sum=sum+arr[i];
System.out.println("calculating sum for thread"+Thread.currentThread().getName()+"sum ="+sum);
try {
Thread.sleep(10);
} catch(Exception e) {}
}
return sum;
}
public static void main(String...d) {
ThreadSafe ts=new ThreadSafe();
ThreadSafe ts1=new ThreadSafe();
Thread t=new Thread(ts);
Thread t1=new Thread(ts1);
t1.start();
t.start();
}
}
Run Code Online (Sandbox Code Playgroud)
我期待输出不会来15.因为sum方法不同步所以多一个线程可以同时执行sum方法
我期待的是因为2个线程会立即执行sum方法所以输出不应该是15,因为第一个线程会将sum的值更新为某个值,该值将被另一个线程读取.
所以我的问题是为什么即使我没有同步sum()方法,程序的输出也按照我期望的方式出现?
我想将评论打印到要在控制台中打印的给定程序?
是否有任何函数和任何自己的逻辑来打印程序中的注释?
例如
int main()
{
/* this is a comment */
}
Run Code Online (Sandbox Code Playgroud)
上面的程序只有一个注释我想通过某个逻辑或任何函数将此注释打印到控制台,如果有C?
我只是编译并运行java程序,但输出很不愉快.我不知道为什么线程处于死锁状态.任何人都可以帮助我理解程序的输出.
class A {
synchronized void foo(B b) {
String name=Thread.currentThread().getName();
System.out.println(name+"entered A.foo");
try {
Thread.sleep(1000);
} catch(Exception e) {}
System.out.println(name+"trying to call B.last()");
b.last();
}
synchronized void last() {
System.out.println("inside A.last");
}
}
class B {
synchronized void bar(A a) {
String name=Thread.currentThread().getName();
System.out.println(name+"entered B.bar");
try {
Thread.sleep(1000);
} catch(Exception e) {
System.out.println("b interrupted");
}
System.out.println(name+"trying to call A.last()");
a.last();
}
synchronized void last() {
System.out.println("inside A.last");
}
}
class DeadLock implements Runnable {
A a=new A();
B b=new …
Run Code Online (Sandbox Code Playgroud) 为什么这些方法
java.lang.Thread.currentThread(),
java.lang.Thread.sleep(),
java.lang.Object.notify(),
java.lang.Object.wait()
of Thread & Object class are not implemented in java API's itself?
Run Code Online (Sandbox Code Playgroud)
为什么需要制作原生方法,这是C/C++编程语言的一部分?
那背后是否有任何区域,或者java无法提供良好的性能?
我正在使用收藏品.困扰我的一件事是:java.util.Iterator接口的方法的实现在哪里?这些方法在哪个类中实现?
public abstract boolean hasNext();
public abstract E next();
public abstract void remove();
Run Code Online (Sandbox Code Playgroud)
我搜索了java API的源代码,但没有在任何类中找到这些方法的实现.
我对以下C代码感到困惑:
int main()
{
const int i=2;
switch(2)
{
case 1:
printf("this is case 1");
break;
case i:
printf("it should be case 2");
}
Run Code Online (Sandbox Code Playgroud)
我知道在关键字之后case
,应该有一个常量表达式.
由于已声明i
为常量,为什么此代码会出现编译错误?
我是C语言的新手.但我可以理解为什么以下代码将输出作为'A'.
困扰我的一件事是printf语句中的数组名称p.编译器正在处理这个p?
如何在第5行之后用字符数组"%c \n"替换p?
我知道这是一个愚蠢的问题,很抱歉发布这个野兔.
任何人都可以帮助我理解这背后的概念吗?
line1: #include<stdio.h>
line2: int main()
line3: {
line4: char p[]="%d\n";
line5: p[1]='c';
line6: printf(p,65);
line7: return 0;
}
Run Code Online (Sandbox Code Playgroud) 可能重复:
没有标题的C程序
我一直在学习C语言.但是困扰我的一件事是,今天我做了一个C程序而忘记包含stdio.h和conio.h头文件我把文件保存为kc.c?当我编译并运行这个.c文件时,输出就像我期望的那样.
但是如何在不使用标准头文件的情况下运行C程序?
或者我不知道我失踪的概念听到了什么?
编辑:该计划
int main()
{
int i=12,j=34;
int *pa=&i,*pb=&j;
printf("the value of i and j is %d %d respectively ",*pa,*pb);
getch();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
因为我在这里使用了STDIO.H头的printf()函数,但没有包括它如何编译并成功运行?
c ×5
java ×4
algorithm ×1
binary-tree ×1
collections ×1
native ×1
notation ×1
performance ×1
pointers ×1
string ×1
tree ×1
turbo-c ×1